Allen's lambda syntax proposal

Brendan Eich brendan at mozilla.com
Sat Nov 29 23:53:27 PST 2008


On Nov 29, 2008, at 11:33 PM, Peter Michaux wrote:

> This would allow writing
>
>  var foo = {|a, b, c| ...};
>
> which could be written even shorter as
>
>  var foo(a, b, c) {...};

Why ever would you want to use 'var' there? Could foo be reassigned to  
denote 42, or "hello"?

Syntax for quite different semantic effects should be composable,  
possibly with compound forms (short-hands for clichéd patterns). But  
it would be wrong to conflate two unrelated ideas (declare a variable;  
define a function) if no use-case wants the full combination.

Yes, ES1 didn't separate function from var enough in this regard, but  
that's a bug (addressed by strict mode in ES3.1).

Some languages use def to introduce constants including constant  
function bindings. So I could see an argument for const foo(a,b,c)  
{...}. But not for var.


> The later is more consistent with the following which would also be
> necessary at times.
>
>  lambda(a, b, c) {...}

Necessary for what use-case?

/be


More information about the Es-discuss mailing list