Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2005-08-05 00:13:18


From: David Abrahams <dave_at_[hidden]>
> 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.

It was just a joke. English is notoriously fraught with
exceptions (pun intended).

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

I've uploaded a set of files that implement my notion of these
things, which I've called multivalues:

   http://boost-sandbox.sourceforge.net/vault/index.php?action=downloadfile&filename=multivalues.zip&directory=rob_stewart&

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

That gives some notion of infix, but it seems entirely too
contrived to me.

What about this:

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

It seems a little better.

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