Why Ruby?

Simen kjaeraas simen.kjaras at gmail.com
Sat Dec 18 15:13:57 PST 2010


Walter Bright <newshound2 at digitalmars.com> wrote:

> Jacob Carlborg wrote:
>> foo(x, y => x * y);
>
> The problem with all these is what is the difference between:
>
>      { x * y }
>      { x * y; }   <== note the ;
>      { return x * y; }

The problem of D's lambda syntax is it is optimized for longer
functions. Usually, the delegates I write are one line long. I cannot
see that this syntax collides with anything at the moment, but feel free
to enlighten me:

{ => 4; }
{ a => 2*a; }
{ a, b => a>b; }
{ => @ + @; } // turns into { a, b => a + b; }

-- 
Simen


More information about the Digitalmars-d mailing list