Allen's lambda syntax proposal

David-Sarah Hopwood david.hopwood at
Sat Dec 6 18:17:34 PST 2008

Eric Suen wrote:
> This is ambiguous
> {(a, b)
> a + b}
> is
> {(a,b);
> a+b
> }

This example isn't ambiguous, because an ExpressionStatement cannot start
with '{', therefore this is a block. However the fact that a lambda
starting an ExpressionStatement would have to be parenthesized is a
valid argument against this syntax, and also against {|a, b| a+b}.

> unless use no line break restrict and it is difficult to parse

It's not actually difficult to parse (since an object literal cannot
have '(' after the '{'), but I don't think it has any advantages over
syntaxes starting with '^' or '\'.

('^' is back on the table given that the semicolon insertion hazard
that caused us to be suspicious of it, already exists when a line
starts with '(', for example.)

David-Sarah Hopwood

More information about the Es-discuss mailing list