Andrew Fedoniouk (2013-07-12T06:48:02.000Z)
domenic at domenicdenicola.com (2013-07-16T00:22:32.792Z)
On Thu, Jul 11, 2013 at 5:08 PM, Brendan Eich <brendan at mozilla.com> wrote: > Very messy, and primordial JS (the "Mocha" interpreter) violated ECMA-262 > Edition 1 on order of evaluation, e.g., o[x] = ++x where the RHS ++x must be > evaluated *after* the Reference o[x] is evaluated. Fixing this prior to > compiling to a parse tree required code buffering and reordering, just as > the for loops (both of 'em) can. > > Again, this goes back to the dawn of JS. We're not making it any worse. I > don't see finite lookahead helping in general for any of these cases, BTW. Compiling this ```js arr[x] = ++x; ``` does not require complete AST support as far as I can tell. Consider this: Some hypothetical bytecode: ``` PUSH arr; PUSH x; -- <RHS code> -> VAL in accumulator register -- SETVI; // stack[TOP-1] <- arr // stack[TOP] <- x, index, initial value of x // accum <- x, final RHS value, x after increment DROP2; // accum here contains x value after increment - result // of the assignment expression. ``` So that can be compiled to stack machine strictly in order it is defined. Or do you mean something else here?