Lambda syntax, etc

Nick Sabalausky a at a.a
Wed Feb 4 10:44:06 PST 2009


"Andrei Alexandrescu" <SeeWebsiteForEmail at erdani.org> wrote in message 
news:gmclr4$2q30$1 at digitalmars.com...
> BCS wrote:
>> 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.
>
> Strings are immune from the problem. :o) Also they make for readily 
> recognizable code because they all use the same argument names.
>
> Andrei

I would be all for the string-style, *if* things like the following were 
fixed:

int foo1(int i) { /*stuff*/ }
void bar(int[] ints)
{
    int foo2(int i) { /*stuff*/ }
    auto x = ints.map!("foo1(a)+foo2(a)")();
}





More information about the Digitalmars-d mailing list