Anonymous function syntax
deadalnix
deadalnix at gmail.com
Wed Sep 21 15:47:06 PDT 2011
Le 22/09/2011 00:29, bearophile a écrit :
> Walter Bright:
>
>> D
>> (a,b) { return a + b; }
>
> In D to define a true lambda you need types too:
> auto f = (int a,int b){ return a + b; };
>
> For D I think I'd like a syntax like:
> { int a, int b => a + b }
> That in some cases becomes just:
> { a,b => a + b }
>
That would be less readable for somebody coming from a C styled
language. Curly braces for body and parenthesis for arguments is
something very familiar.
This makes Javascript's and D's closures the most readable for somebody
having this background.
More information about the Digitalmars-d
mailing list