That hash symbol
mikesamuel at gmail.com
Tue Mar 29 16:11:22 PDT 2011
2011/3/29 Mike Samuel <mikesamuel at gmail.com>:
> 2011/3/29 Bob Nystrom <rnystrom at google.com>:
>> Wouldn't => work the same way?
>> (a, b) =>
>> It parses "(a, b)" thinking it's a grouped comma operator (not exactly a
>> common expression FWIW), then it hits "=>" realizes it's a function
>> parameter decl, and then either backtracks or just transforms the left-hand
>> AST into a param decl.
> An AST won't cut it. You have to use a parse tree because there are
> valid grouped comma operators containing only identifier operands that
> are not valid parameter lists, e.g. ((a), b)
> Once you do have a way to make the necessary distinctions, => is just
> another right associative operator that you need to pick a precedence
The fact that there are parameter lists that are not valid grouped
comma operators, () and (a), shouldn't cause problems.
And there shouldn't be any subtle semicolon insertion bugs.
bar = foo
will reliably produce a syntax error when the parameter list is stolen
by a callable expression on a previous line.
More information about the es-discuss