Expression closures - use-cases for shortcut lambda syntax (blocks)

Brendan Eich brendan at
Fri Mar 16 15:22:22 PDT 2007

On Mar 16, 2007, at 2:17 PM, Vassily Gavrilyak wrote:

> Brendan: No, I didn't meant \(, I meant exactly (\

Sorry, I mis-remembered your blog post (http:// 
javascript_2_ecmascript_editio.html#comments). Indeed you have always  
written (\ formals ) expression -- but now I'm cooling, not warming,  
to the (\ proposal.

> We dumped  all those 3 'bigs' in favor  of JS and never looked   
> back  since.
> And everybody accepted the proposal to hack the lexers only to show  
> the clear intent in the code, so everybody will understand what's  
> going on.

I agree with an earlier poster that clarity depends on one's  
background, therefore familiarity can make idioms clear.

Digression: sometimes "idiom" is abused to mean "cliché", but the  
latter is just a common phrase or construct, whose meaning may or may  
not be clear from denotation and connotation of component words or  
symbols. "Idiom" is something like the English phrase "kick the  
bucket" (meaning to die), whose definition cannot be deduced from its  
components. With your proposed lambda syntax, (\ formals )  
expression, we definitely have another idiom for JS hackers to learn.

This idiom would not re-use brain-print from any other popular  
language. So familiarity would have to be acquired at some cost. That  
cost may be no lower or higher than the cost of learning expression  
closures as proposed (function (formals) expression), but it seems  
higher to me given the oddness of (\.

> To conclude:
> -Proposal is about clarity, not terseness, please do not accept it  
> as 'just to save 6 keystrokes'

Seven keystrokes, by my count.

> -Not everybody has C/C++/Java background. Lot of people have Perl,  
> Ruby, PHP background.

But (\ is unclear to users of those languages, it is a new idiom.

> -Blocks with proposed syntax are simple to implement and do not  
> break current code.

True, but same goes for expression closures.

> -Provided use-cases are widespread in web-programming and are  
> currently hard to write and read clearly in ES3.
> Blocks can fix this.

"Hard to write" must mean those seven extra keystrokes. I'm  
sympathetic to a point, but readability trumps writability.

"Hard to read" must mean hard on account of the repeated "function"  
word, which becomes noise to signal at scale. I'm sympathetic to  
this, I often comment on it (e.g. when I show the Y combinator in JS  
in presentations such as the one I gave at ICFP 2005).

However, (\ is really an abuse of backslash, as others have noted.

It looks less like a lambda every time I see it (subjective, but I'm  
just giving my opinion).

I agree that there's no point in adding a "block" keyword.

So without an idiom from another language, I'm cool again. Sorry, but  
feel free to propose a better syntax. We are not out of room in the  
grammar yet!


More information about the Es4-discuss mailing list