Why Ruby?
retard
re at tard.com.invalid
Sun Dec 19 04:35:22 PST 2010
Sun, 19 Dec 2010 01:24:43 +0000, JRM wrote:
> On Sat, 18 Dec 2010 16:01:37 -0800, Walter Bright wrote:
>
>> 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"
>>
>> ?
>
> I agree that those aren't really much better. This entire discussion
> seems a little odd to me. People are trying to find a way to more
> easily write lambda's, focusing in particular on single expression
> lambda's.
Have you got any idea what a 'lambda' actually is? It originates from the
lambda calculus. In lambda calculus the lambda abstraction is something
that takes a single argument and returns an *expression*. You can argue
that this is less general than D's delegates, but the fact is that many
such functions such as sort, filter, map, reduce, ... return an
expression. Of course the explicit return generates additional syntactic
bloat.
> In order to support lazy, D already allows an expression to be
> implicitly converted to a delegate returning either void or the type of
> the expression. This covers the case of lambda's taking no arguments,
> and happens to be shorter than any of the proposed syntaxes.
Sorry, don't remember how this works in D if you actually call the
function with a delegate that isn't taking any arguments, but if the lazy
generates another thunk, this doesn't work consistently.
> I think this idea (or something similar) is worth consideration. It is
> simply a small extension to an already existing feature that would give
> D a terser syntax for lambda's than most of the other languages we've
> been discussing.
So in your opinion D's function literals should only be improved if you
can somehow outwit existing languages, otherwise it just sounds like a
stupid idea?
More information about the Digitalmars-d
mailing list