return when desugaring to closures

Brendan Eich brendan at mozilla.com
Thu Oct 16 15:40:06 PDT 2008


On Oct 15, 2008, at 1:28 PM, Mark S. Miller wrote:

> On Wed, Oct 15, 2008 at 12:31 PM, Dave Herman <dherman at ccs.neu.edu>  
> wrote:
>> Do you prefer (lambda Formals Block | lambda Formals Expression)?
>> [Personally I'm fine with that.] Or do you oppose any lambda  
>> expressions
>> at all? Or did you have something else in mind?
>
> My preference is
>
>    "lambda" Formals? Block
>
> Since an invocation of the closure evaluates to its completion value,
> the only savings of introducing the Expression form would be a pair of
> curlies. This is too small a benefit to justify another case in the
> grammar. Further, in exchange for always requiring the curlies, we can
> make the formals optional. Once we've got lambda, we'll start using
> them for control abstractions, in which case the no-parameter form
> will become quite common. I'd rather be able to leave out the parens
> than the curlies. YMMV. This is admittedly subjective, but you did ask
> about preferences.

Hi Mark,

That's fair and closely reasoned, but I question the likelihood of  
zero-argument lambdas emerging in control abstractions favored by all  
that many users. For now I favor the lambda expression form as well as  
the lambda block form. You're right that much of this is subjective,  
not just personal but also speculative about what users will tend to  
use.

Expression closures are already insanely popular in JS1.8, of course  
used only in Mozilla-specific code. They'd be even more winning as  
lambdas, whether zero args is common or not (six letter keyword  
instead of eight), but losing the braces is part of the win. The two  
shifted chars are not easy on some peoples' hands (ask Python hackers  
who are spared such RSI-inducing chords). The visual weight is less,  
to boot.

Definitely my two cents, no more (possibly fewer ;-).

/be


More information about the Es-discuss mailing list