On Fri, Jul 19, 2013 at 5:43 PM, Tab Atkins Jr. <[email protected]>wrote:

> On Fri, Jul 19, 2013 at 2:22 PM, Rick Waldron <[email protected]>
> wrote:
> > On Fri, Jul 19, 2013 at 3:21 PM, Tab Atkins Jr. <[email protected]>
> > wrote:
> >> On Fri, Jul 19, 2013 at 1:21 PM, Rick Waldron <[email protected]>
> >> wrote:
> >> > While this is all true, the simple answer is:
> >> >
> >> > var a = 1, b = 2, c = 3;
> >> > a < b < c; // true
> >> >
> >> > is already valid JavaScript and can't be co-opted to express new
> runtime
> >> > evaluation semantics.
> >>
> >> Well, that's a bad example, because it's true with chained operators
> >> too.  Let c = 1.5, though, and you get different behavior.
> >
> > It doesn't matter if you think my example is a "bad example", it's a
> valid
> > expression per the language's existing grammar.
>
> It certainly does, because we don't expose the parsing directly.  If
> we change the interpretation of a piece of code, but it outputs the
> same or compatible values, we're fine.  It's only when the observable
> results change incompatibly that we have to worry.  In your example,
> you get a "true" regardless of the interpretation, which means you're
> not demonstrating a problem with changing the interpretation.
>

You have completely missed my point, please refer to the grammar
specification that has existed since the first edition, published in 1997:

MultiplicativeExpression :
    UnaryExpression
    MultiplicativeExpression * UnaryExpression
    MultiplicativeExpression / UnaryExpression
    MultiplicativeExpression % UnaryExpression

AdditiveExpression :
    MultiplicativeExpression
    AdditiveExpression + MultiplicativeExpression
    AdditiveExpression - MultiplicativeExpression

 ShiftExpression :
    AdditiveExpression
    ShiftExpression << AdditiveExpression
    ShiftExpression >> AdditiveExpression
    ShiftExpression >>> AdditiveExpression

RelationalExpression :
    ShiftExpression
    RelationalExpression < ShiftExpression
    RelationalExpression > ShiftExpression
    RelationalExpression <= ShiftExpression
    RelationalExpression >= ShiftExpression
    RelationalExpression instanceof ShiftExpression
    RelationalExpression in ShiftExpression

EqualityExpression :
    RelationalExpression
    EqualityExpression == RelationalExpression
    EqualityExpression != RelationalExpression
    EqualityExpression === RelationalExpression (ES3+)
    EqualityExpression !== RelationalExpression (ES3+)


Unambiguously and in no uncertain terms, the following is a completely
valid expression (ie. will not throw a SyntaxError exception):

100 % 1 < 1e1 > 0xff - 5 + (+5) < 10 > 1.5 - 1..toString() === (function()
{}()) !== parseInt(1, 10) * 1 | 0 >>> 1;
// 1

It doesn't matter if the parsing isn't exposed, or broken in the first
place, or a bad example, or not what you want, there is a formally defined
grammar in a published standard. Hopefully I've cleared up any remaining
questions or previously unclear points.


Rick
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to