Lambda syntax, etc
Nick Sabalausky
a at a.a
Mon Feb 9 22:13:38 PST 2009
"grauzone" <none at example.net> wrote in message
news:gmpgod$fej$1 at digitalmars.com...
> bearophile wrote:
>> Let's play more; then what do you think about (all the following are
>> legal):
>>
>> auto r1 = range.find({ x -> x.weight > 100 });
>> auto r2 = range.find({ x :: return x.weight > 100; });
>> auto r3 = range.find({ x :: stmt1(x); stmt2; });
>> auto r4 = range.find({ x, y :: stmt1; return foo(y); });
>>
>> I like those enough, they seem balanced, uniform, not too much
>> error-prone, they have only one visual chunk, short enough and easy to
>> write :-)
>
> Agreed.
>
> Especially I like that "normal" and "functional" uses have distinct
> syntax. This is much better than the proposal, to allow omission of the
> return statement, and to return last value of the last expression
> statement instead (like in (x){if(x>0) x+=1; x;}).
>
I'd rather have everything use "::" (consistent), and then say that the
right-hand side of :: can be either A: one or more statements ("normal") or
B: an expression ("functional").
More information about the Digitalmars-d
mailing list