Block lambda is cool, its syntax isn't

Brendan Eich brendan at
Thu Jan 12 16:53:21 PST 2012

... continuing with my sent-too-soon message:

    function() {
        asyncAction(..., { (a, b) a.add(b); } }

You're right, this could be done. Allen's right that aesthetics matter, 
and so (aesthetic sensibilities in various people were formed by these) 
do older languages. Ruby uses || not (). Smalltalk uses | but 
differently, and of course does not use {}.

Apart from aesthetics, I argue that || are better because they are 
different from the overloaded () pair, which mean expression grouping in 
the nearby context of the body of the block-lambda, e.g. a.add()b; 
above. () also are used around formal parameter lists. And of course 
they are used for control structure heads, e.g. if (foo).

Rather than overloading () yet again, for a different formal parameter 
list context (block-lambda parameter list after {), which is immediately 
adjacent to an expression-statement contexts (the block-lambda body), I 
believe we should use ||.

The Ruby precedent is another reason, and a particular reason to use | 
instead of some other candidate. But I'm mainly trying to persuade you 
here that () is not the best choice just because it brackets formal 
parameter lists for functions.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list