|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-08-03 05:11:47
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.
Besides, >, >=,<=, < aren't symmetric ;^)
>> > 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.
>
> 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)
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.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk