A nice way to step into 2012
deadalnix
deadalnix at gmail.com
Wed Dec 28 09:15:04 PST 2011
Le 28/12/2011 13:54, bearophile a écrit :
> Timon Gehr:
>
>> => expr
>>
>> should imo be a shorthand for
>>
>> () => expr.
>>
>> It saves some ((())(()))().
>
> It saves few (), but zero argument lambdas aren't that common in my functional-style code, and I think it decreases syntax uniformity and code readability. So I think it's a bad idea.
>
> On the other hand I think extending the applicability of this syntax to free functions/methods (as in Scala and Ada2012) is a nice idea, to shorten tiny functions/methods, that are common enough:
>
> class C {
> private int x;
> int getX() => x;
> }
>
That would be great ! Uniformity is something we should look for.
> ------------------------
>
> Walter:
>
>> They expect to see it, or else they mark D as "not having lambdas" and "not supporting functional programming".<
>
> To me this sounds like a bit silly argument to base language design on.
>
> In my opinion the most important reason for the introduction of this anonymous function syntax is that it makes D functional-style code (and generally code that uses lot of callbacks) less noisy, so it makes it more easy to write and read.
>
> Bye,
> bearophile
Both argument are fallacy. Javascript is a successful language (even if
some design decisions are arguably very bad). It use a lot of callback,
and promote event drivent programming so this type of consrtruct is used
everywhere. In addition, in Javascript, code source size matters.
The syntax to do such a thing is more verbose in javascript. So
definitively, this is a nice syntax, but this isn't that ground
breaking, and this isn't even required for people to use this type of
constructs.
More information about the Digitalmars-d
mailing list