On Jun 19, 2011, at 4:04 PM, Brendan Eich wrote:

> On Jun 19, 2011, at 3:17 PM, Claus Reinke wrote:
> 
>> https://github.com/clausreinke/jstr/tree/master/es-discuss
>> 
>> You can find there the proposal text, with motivation, grammar changes, 
>> semantics (entirely via desugaring to existing syntax), and related issues, 
>> as well as a prototype implementation, using jstr's nascent grammar-based 
>> ES-to-ES rewriting:
>> 
>>   tailnests.txt: proposal text
> 
> 
> Quick reply to point out that:
>     FunctionExpression :
>       function Identifier_opt ( FormalParameterList_opt ) { FunctionBody }
> +     function Identifier_opt ( FormalParameterList_opt ) => 
> AssignmentExpression
> 
> inverts precedence, as MemberExpression : FunctionExpression but now 
> FunctionExpression can end with a low-precedence expression 
> (AssignmentExpression).
> 
> For example, the last line in
> 
>   function f(x) => x;
>   z = a + function (b) => b ? f : x++(1);
> 
> parses awkwardly, as ( z = ( a + ( function (b) => ( b ? f : ( x ++ ) ) ) (1) 
> ) ).

This is not just awkward, of course -- the grammar you propose is ambiguous. 
The precedence inversion means there are two ways to parse

  z = a + function (b) => b ? c : d;

Either as

  z = (a + (function (b) => b)) ? c : d;

or as

  z = a + (function (b) => (b ? c : d));

And we've been around this block before. Ambiguous grammars are future-hostile.

/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to