ECMA-262: ElementList : ... AssignmentExpression? Wtf?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

ECMA-262: ElementList : ... AssignmentExpression? Wtf?

Uncloud Group
Why does a ArrayLiteral element  use AssignmentExpression, but on any implementation works like a PrimitiveExpression? E.g.:

[ a = b ]

AssignmentExpression is something very different. I'm just confused.

[ x = y ]

What is this, my boys?

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: ECMA-262: ElementList : ... AssignmentExpression? Wtf?

Uncloud Group
The first example was meant to be [ a, b ]. Sorry.

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: ECMA-262: ElementList : ... AssignmentExpression? Wtf?

Brendan Eich-6
Expression is .comma expression so can't be used without fatal ambiguity: is [a,,b] [(a,b)] or [(a), (b)]? It's the latter by using AssignmentExpression. If it were PrimaryExpression, ever expression using a binary operator would need to be parenthesized.

Is the "Dragon Book" still in print? Recommended.

/be

On Sun, Oct 29, 2017 at 5:49 AM Uncloud Group <[hidden email]> wrote:
The first example was meant to be [ a, b ]. Sorry.
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: ECMA-262: ElementList : ... AssignmentExpression? Wtf?

Logan Smyth
Assuming I'm following your question, it seems like the confusion here is that `AssignmentExpression`, name-wise, seems like it is only for assignment, but in reality most of the other expression grammars are nested inside it? If you look at https://www.ecma-international.org/ecma-262/8.0/#sec-expressions you can see for instance

 Inline image 1

and the `ConditionalExpression` drills down even further, eventually reaching all of the normal "expression" types that you'd expect in JS.

`AssignmentExpression` in the ECMAScript grammar essentially translates to "any expression except comma expressions.

On Sun, Oct 29, 2017 at 7:53 PM, Brendan Eich <[hidden email]> wrote:
Expression is .comma expression so can't be used without fatal ambiguity: is [a,,b] [(a,b)] or [(a), (b)]? It's the latter by using AssignmentExpression. If it were PrimaryExpression, ever expression using a binary operator would need to be parenthesized.

Is the "Dragon Book" still in print? Recommended.

/be

On Sun, Oct 29, 2017 at 5:49 AM Uncloud Group <[hidden email]> wrote:
The first example was meant to be [ a, b ]. Sorry.
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

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



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