While we were discussing lambda syntax..

Philippe Sigaud philippe.sigaud at gmail.com
Sat Jan 1 00:56:25 PST 2011


> Well, while we were arguing about a new syntax, a clever fellow named Phillipe Sigaud has already come up with a way to use predicates without resorting to strings:
>
> auto arr = [0,1,2,3,4];
> auto plusOne = map!(_0 + _1)(arr);
>
> Check it out: http://svn.dsource.org/projects/dranges/trunk/dranges/docs/lambda.html
>
> Make sure you read the features section. Is that awesome or what?

Hi Andrej,

thanks for the kind words, but don't expect too much from this module.
It was just an afternoon fun, as I was trying to 'get' expressions
templates.
E. Niebler's articles on boost::proto on cpp-next.com are an
interesting read for a much-more-expanded module.

As I said in the docs, I got stuck at comparison operators. a <  b is
automatically transformed by the compiler into a.opCmp(b) < 0.
a.opCmp(b) becomes another lambda and the '< 0' part triggers another
expansion, ad infinitum...
That totally destroy any interest this module could have. I mean,
mapping and reducing are good, but I want filtering too, and filters
demand comparison lambdas.
As yet, filter!(_ < 0)(arr) doesn't work. Too bad.


Philippe.


More information about the Digitalmars-d mailing list