Lambda syntax, etc
BCS
none at anon.com
Wed Feb 4 09:55:25 PST 2009
Hello bearophile,
> I've taken a look at the syntax for lambda in other C-like languages.
> This is from Functional Java:
> http://functionaljava.org/examples#Array.filter
>
> In Functional Java you can write this D syntax:
> (int i, int j) { return i % 3 == j; }
> as:
> { int i, int j => i % 3 == j }
That syntax, and a few of the below, show the one major gripe I have with
ultra-compact lambdas: it's hard to *quickly* spot the args/code transition.
[...]
> i => i % 3 == 1 // C#3
>
> i => { return i % 3 == 1; } // C#3, with statements too
>
> To define a delegate o delegate closure:
>
> Func<int> foo = i => { return i % 3 == 1; };
>
> Func<int> foo = i => i % 3 == 1;
>
> Func<int> bar = () => 2;
>
More information about the Digitalmars-d
mailing list