Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2005-08-03 09:19:15


Rob Stewart <stewart_at_[hidden]> writes:

> 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! ;-)

Not when english expresses what we mean more concisely.

>> Besides, >, >=,<=, < aren't symmetric ;^)
>
> I swapped predicates accordingly.

The notion of symmetry here is twisted anyway. 3*x == 1+y is not the
same as 1+x == 3*y.

>> >> > 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?

The latter.

>> > 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.

  all_of(a)._(frobnicates, any_of(b))

  all_of(a)._,frobnicates, any_of(b)

  all_of(a)._ %frobnicates% any_of(b)

  all_of(a)._ |frobnicates| any_of(b)

  all_of(a)._ <frobnicates> any_of(b)

(etc)

-- 
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