While we were discussing lambda syntax..

Alex_Dovhal alex_dovhal at yahoo.com
Fri Dec 31 08:45:16 PST 2010


"Andrej Mitrovic" <none at none.none> wrote:
> There was some heated discussion about the disadvantages of using strings 
> as a predicate, and coming up with some new syntax that DMD would support. 
> Some people did not like using strings and would rather use _ or _0/_1 
> instead of this:
>
> auto arr = [0,1,2,3,4];
> auto plusOne = map!("a + b")(arr);
>
> 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?

Personally I like string lambdas because they are shotrest possible and easy 
to see.
But still if you experiment with language, would f!{_0 < _1} syntax be 
acceptable if possible? 




More information about the Digitalmars-d mailing list