return when desugaring to closures

Brendan Eich brendan at mozilla.com
Sat Oct 11 16:50:40 PDT 2008


On Oct 11, 2008, at 4:02 PM, Mark S. Miller wrote:

> Let's say, further, that
> a lambda's parameter list is syntactically optional.

This makes for ambiguities if we do not require a braced expression,  
as Dave pointed out. Requiring braces always goes against the  
expression/statement unification thrust of the proposal. Letting  
(formals) be omitted only if a { follows lambda seems like too much  
special-casing.

Most lambdas will take at least one parameter, judging from existing  
languages and use of functions in JS. It is not obviously worth the  
complexity in avoiding ambiguity just to cater to the zero-formals  
case. I say it's not, since if () is two chars too many, then -bda is  
still three too many (lam- ties let).

The let block/expression idea, however it shakes out, should be viewed  
as sugar for (lambda (bindings) body)(...). There the savings is at  
least (bda)() or seven chars, four of them noisy and shifty (RSI- 
inducing, but who's counting given our C heritage :-P) punctuation.

We can argue about the merits of sugar (tooth decay? longevity via  
reduced stress? natural sweeteners combined with complete nutrition  
are not associated with tooth decay -- ok, I'll stop now ;-)), but if  
we keep this discussion separate from lambda's syntax and semantics,  
then I think both lambda and any let block/expr sugar that emerges  
will benefit.

/be


More information about the Es-discuss mailing list