Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2005-08-03 06:11:11


From: David Abrahams <dave_at_[hidden]>
> Rob Stewart <stewart_at_[hidden]> writes:
>
> > Florian's notion of these operators, derived from Perl, is that
> > they are not symmetrical. To make expressions like 1 and 2
> > symmetrical, I've taken to swapping arguments depending upon the
> > combination of types, which means I'm forcing the symmetry.
> > Maybe I'm just off the mark and they should be allowed to be
> > asymmetrical.
>
> I think that's right. These things reflect the syntax and semantics
> of english, not of math anymore.

That's always a bad sign! ;-)

> Besides, >, >=,<=, < aren't symmetric ;^)

I swapped predicates accordingly.

> >> > Reasoning
> >> > over the result of using none_of() with a user-defined predicate
> >> > gets quite difficult when compared against an all_of() or other
> >> > junction/multivalue objects. Doing so against a single value is
> >> > much easier.
> >> >
> >> Yes but the documentation should say what combinations
> >> are potentially dangerous.
> >
> > Dangerous? Inefficient or useless, maybe, but dangerous?
> >
> >> > I think "evaluate" is better than "is_true_that:"
> >> >
> >> > if (evaluate(all_of(a), _1 >= _2, one_of(b))) ...
>
> Yuck.

Do you prefer "is_true_that" or were you registering distaste for
both?

> > Perhaps we should consider a functional style:
> >
> > if (compare(all_of(a), one_of(b), _1 >= _2))
> >
> > or
> >
> > if (compare(all_of(a), _1 >= _2, one_of(b)))
>
> IMO that's a *lot* harder to read than
>
> all_of(a) >= one_of(b)

Of course.

> I'm not sure if I'm going to like the latter style in the long run,
> but so far it's looking pretty sweet.

What about user-supplied predicates? You can't use infix
notation then.

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk