Compatibility issue ES3/ES4, your prompt replies are encouraged.
The versioning discussion has had two solutions: the mime type provides the value for a script, telling the implementation how to parse it; and a global variable or perhaps scoped parameter (the semantics are unclear as of yet) called __ECMASCRIPT_VERSION__ can be tested by the program, eg when it wants to insert new SCRIPT tags.
But how will eval cope? It invokes the compiler but has no provisions for script version, and there are two more wrinkles:
- ES3 programs (ie programs that originate from scripts whose mime type indicates an ES3 style script) that call eval must get ES3 behavior automatically (let is a variable and all that).
- ES4 programs will presumably expect ES4 behavior automatically, too.
Three cases.
1) eval(s). Here eval is an operator. The code for the operator can in principle be customized during compilation of the containing script, so it can have version-specific behavior.
2) window.eval(s). The value of window.eval is an object with identity, if it has different behavior based on its caller it must be able to inspect its caller and its caller's environment (eg to find out what its caller's notion of __ECMASCRIPT_VERSION__ is). This is doable. Is it what we want? Or do we want window.eval to choose the lowest version among the scripts loaded into that environment? This will almost always be ES3 because of event handlers, which are not mimetyped and hence have to be handled as ES3.
3) f = eval; f(s). Since the use of eval here means the same as if window.eval were used, this is like case 2; if f is passed to a different frame it will still use the environment in which it's closed, ie, the frame from which it was extracted.
This is really a web-only issue, we could leave it unspecified, but since we're elevating versioning into the spec (also only for the web) we should probably cover it.