Allen's lambda syntax proposal

David-Sarah Hopwood david.hopwood at industrial-designers.co.uk
Sun Dec 7 21:59:35 PST 2008


Alex Russell wrote:
> On Dec 5, 2008, at 9:23 PM, David-Sarah Hopwood wrote: 
>> P T Withington wrote:
>>> Would it work to move the parameter list inside the block (as in the
>>> Smalltalk way, but as a regular parameter list, not using ||'s)?
>>>
>>>  {(a, b) a + b}
>>>
>>> AFAICT, `{(` is a syntax error for an expression in es3.
>>
>> I think this is unambiguous, but I don't like it because it has no
>> symbol or combination of symbols that is specific to a lambda.
>> ( "{(" can occur as the start of a block.)
>
> Indeed, it can look like an expression to begin a name assignment:
> 
>     var thinger = {("foo"+"bar"): ... };

No, property names in object literals are required to be a single
IdentifierName, StringLiteral or NumericLiteral.

> Has a syntax like this been shot down yet?:
> 
>     var thinger = {{ foo, bar }: ... };
> 
> Since objects (much less literals) aren't used as keys in hashes often,
> this strikes me as being somewhat less ambiguous. The short (no args)
> version might then be:
> 
>     var thinger = {: ... };
> 
> Arguments against?

What is the advantage of this syntax over ^(a, b) {a+b}, for example?

Ditto for P T Withington's proposal of ^{(a, b) a+b}.

-- 
David-Sarah Hopwood


More information about the Es-discuss mailing list