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
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss