Why Ruby?

Nick Sabalausky a at a.a
Sat Dec 18 16:15:30 PST 2010


"Nick Sabalausky" <a at a.a> wrote in message 
news:iejimj$11qt$1 at digitalmars.com...
> "Walter Bright" <newshound2 at digitalmars.com> wrote in message 
> news:ieji4j$10k5$1 at digitalmars.com...
>> Simen kjaeraas wrote:
>>> 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; }
>>>
>>
>> If size and simplicity of typing are critical, are those really better 
>> than:
>>
>>   "a>b"
>>
>> ?
>
> Yes, because in practice "a>b" must end up being evaluated in the wrong 
> scope. I've used std.algorithm very little so far, and yet I've still 
> found that limitation to be a problem.
>
> There's also the minor quibble that "a>b" doesn't get highlighted right, 
> but that's obviously solvable with q{a>b}.
>

One other issue with the string: You can't pass it to a function that 
expects an actual delegate. It may or may not be possible to make a 
conversion function, but even if so, you'd lose the simplicity/brevity which 
was the whole original point.

All in all, it's just platering over the problem.




More information about the Digitalmars-d mailing list