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

Brendan Eich brendan at
Mon Mar 19 15:23:18 PDT 2007

On Mar 19, 2007, at 2:35 PM, Jeff Dyer wrote:

>> Your argument is not consistency, but brevity: "because the latter
>> erase characters from the current function expression form, while the
>> former adds '=>'". A different consistency argument, with the new
>> lambda syntax, favors =>
> I'm arguing for consistence too. The keyword forms of function are
> visually more closely related than the two expression forms. Let
> statements and expressions support this relationship.

Oh, right -- sorry I didn't remember the let expression form's  
influence here.

> What we do for
> function expressions we should do for let expressions.

That's one way to be consistent with another form, yeah. It's not the  
only way, in light of the new => based expression closure syntax.

>      let (x=y) x
> become
>      let (x=y) => x
> But => has limited appeal to me. I'd like to use it only as we agreed
> yesterday, in function expressions without a 'function' head. In all
> other contexts it just adds clutter.

I'm not so sure, having been through an implementation cycle (JS1.7  
in Firefox 2) of let blocks and expressions. Users have not cried out  
for => or = clutter, but there has been some confusion about lack of  
braces meaning let expression.

It's true you did not feel the urge to use = between let head and  
expression body, as you did when Dave proposed expression closures  
via the 'function (formals) expr' syntax. But the same consistency  
argument you make now might have applied to that desire for 'function  
(formal) = expr'.

There's no hard or fast rule here. Aesthetics matter, but usability  
should trump if in conflict. Alas we don't have much usability data.  
I'll try to get some based on JS1.7.


More information about the Es4-discuss mailing list