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

Brendan Eich brendan at
Fri Mar 16 18:37:16 PDT 2007

On Mar 16, 2007, at 5:34 PM, Vassily Gavrilyak wrote:

> Well, I agree, it is available such way too.
> And it is avalivaible with try {} finally{} from long time ago.
> It's just the same issue of readability.
> The question - what is for doing here, where is the loop  
> immediately come to mind when reading such construct.
> The same for try - what this code is supposed to catch here? 20  
> lines below - ah, nothing, that was for closing resource.
> We can even do this with if, goto, while, switch anything.
> But there are better ways :-)

There are duals competing in language design. You see this in Python,  
where comprehensions and generators are favored over more functional  
programming idioms (hence the crippled one-line lambda). Some  
languages start with lambdas and grow sugar (comprehensions) and  
iterable coroutines (generators). I'm hesitant to pick a winner, and  
we have already said that we don't believe in minimizing JS/ES into a  
shiny, Scheme-like jewel that requires users from beginner to  
intermediate skill level to become too expert too soon.

We want conveniences, especially where they reflect existing practice  
in JS and "nearby" languages (I argue Python is one such language).  
We will always have first-class functions.

Given all this generalization, I would like to make a particular  
suggestion: keep focusing on expression closure use-cases, and show  
"A" vs. "B" examples with the different suggested syntaxes (all  
suggestions). Pick use-cases that come from real code, Ruby or  
whatever. Don't use miniature fakes. Then perhaps we can come to  
agreement quickly.


More information about the Es4-discuss mailing list