On Jan 5, 2012, at 8:24 PM, Mark S. Miller wrote: > Hi Allen, if ES5 had only one mode, I'd understand this. But I thought we > were trying to arrive at two modes, ES6 non-strict, to be backwards compat > with ES5-non-strict, and ES6 strict, to be backwards compat with ES5-strict. > I am perfectly happy to call ES6 non-strict "ES3", since ES5-non-strict > really exists to be an ES3 compatibility mode, and was constrained to be > backwards compatible from ES3. Likewise, I am happy to call the new ES6 > strict simply "ES6". > When I talked about "ES5" in my original post I meant full ES5 including both strict and non-strict modes. Since ES6 is supposed to be a strict super set of ES5 strict mode, anything in the ES5-only category must be an exclusively non-strict mode feature (for example, with). I suppose you could call that category "ES3" but I decided to label it "ES5-only" to keep things focused on differences between ES5 and ES5.
> Concretely, I am confused how your transition diagram is supposed to handle > "use strict";. Reading your state machine literally, since "use strict"; is > accepted by ES5, if it is accepted by ES6 (as I think we all agree it would > be), then it would leave us in state ES5&ES6. Were you two base categories > "ES6 non-strict" (or ES3) and "ES6 strict" (or ES6), then a "use strict"; > would put us in your ES6 strict (or ES6) category, which is what I would have > expected. Yes, "use strict" is in the ES5&ES6 category. A ES5 completely strict mode program would start in State 5&6 and stay in that state for its entire "compilation". Only encountering use of a new ES6 feature would case a transition to State ES6. Looking at it another way, Both State ES5 and State 5&6 include support for both strict and non-strict ES5 code. State ES6 only allows strict code. Allen > > > On Thu, Jan 5, 2012 at 6:37 PM, Allen Wirfs-Brock <al...@wirfs-brock.com> > wrote: > Here is a possible set of rules for implicitly assigning ES5 or ES6 semantics > to a Program unit > > In an "ES6" implementation, all constructs that can occur in a valid program > fit into one of these categories: > ES6-only: The construct is based upon syntax or static semantics rules that > only exist in ES6. For example, a destructuring pattern > ES5-only: The construct is based upon syntax that or static semantics rules > that that are not in ES6. For example, use of a with statement t. > ES5&ES6: The construct has identical semantics in both ES5 and ES6. > ES5~EAS6: The construct has identical syntax and static semantics in both > ES5 and ES6, but differing semantics. For example, accessing a formal > parameter after an assignment to the corresponding element of the function's > arguments object. > > We can then use the following state machines to describes the processing of a > Program based upon the occurrence for these feature categories. Initially > start in State 5&6: > > State 5&6 > if current construct is in ES5&ES6, process using intersection semantics, > then goto State 5&6 > if current construct is in ES5~ES6, process using ES5 semantics then, > goto State Compat5 > if current construct is in ES5-only, process using ES5 semantics then > goto State ES5 > if current construct is in ES6-only, process using ES6 semantics then > goto State ES6 > > State ES5 > if current construct is in ES5&ES6, process using intersection semantics, > then goto State ES5 > if current construct is in ES5~ES6, process using ES5 semantics, then > goto State ES5 > if current construct is in ES5-only, process using ES5 semantics then > goto State ES5 > if current construct is in ES6-only, terminate with Error: invalid > combination of ES5 and ES6 features > > State ES6 > if current construct is in ES5&ES6, process using intersection semantics, > then goto State ES6 > if current construct is in ES5~ES6, process using ES6 semantics, then > goto State ES6 > if current construct is in ES5-only, terminate with Error: invalid > combination of ES5 and ES6 features > if current construct is in ES6-only, process using ES6 semantics then > goto State ES6 > > State Compat5 (or have an analogous Compat6 state, and restart to State ES5 > when necessary) > if current construct is in ES5&ES6, process using intersection semantics, > then goto State Compat5 > if current construct is in ES5~ES6, process using ES5 semantics then, > goto State Compat5 > if current construct is in ES5-only, process using ES5 semantics then > goto State ES5 > if current construct is in ES6-only, abort current compilation and > restart from beginning, starting in State ES6 > > Basically using any ES6 features makes it an ES6 program. Using any ES5-only > feature makes it an ES5 program. > Combining ES5-only and ES6 features results in an invalid program. > If a Program can not be explicitly identified as either ES5 or ES6, it is > treated as an ES5 program. > > If you want to explicitly force ES6 processing put a: > let ES6; > at the top of the source file. > > If you want to explicitly force ES5 processing put a: > with (5); > at the top of the source file > > Allen > > > > > > -- > Cheers, > --MarkM
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss