Allen's lambda syntax proposal

David-Sarah Hopwood david.hopwood at
Fri Dec 5 21:01:11 PST 2008

David-Sarah Hopwood wrote:
> Peter Michaux wrote:
>> The syntax ^(){} has a semicolon insertion ambiguity. What does the
>> following mean?
>>   x = x
>>   ^(){}
> It's not ambiguous; it would mean "x = x^(){}", which is (in this case)
> a syntax error.
> '-' and '/' already have a similar issue of possibly unexpected
> parsing when they occur at the beginning of a line.

and '+', '++', '--', '(', and (for a different reason) 'function'.

Actually, the case of '(' is arguably worse than '^', because '('
at the start of an ExpressionStatement is very common:

  x = x

(parsed as 'x = x(foo);', but intended to be 'x = x; (foo);').

> Note that programmers who never deliberately rely on semicolon insertion
> will not be surprised by this example; they will consider writing
> "x = x" without an terminating semicolon to have been their mistake.

David-Sarah Hopwood

More information about the Es-discuss mailing list