Forwards-compatible syntax proposal
liorean
liorean at gmail.com
Mon May 26 19:18:29 PDT 2008
2008/5/27 Nathan de Vries <nathan at atnan.com>:
> <script type="application/javascript">
> /*<![CDATA[*/
> var ES3ProtoClass = Class({
> initialize: function() {
> this.es4instance = new ES4Class;
> }
> });
> /*]]>*/
> </script>
>
> <script type="application/javascript;version=2">
> /*<![CDATA[*/
> class ES4Class() {
> private const es3instance;
>
> function ES4Class() {
> es3instance = new ES3ProtoClass();
> }
> }
> /*]]>*/
> </script>
>
> What does "new ES4Class" mean to a user agent that does not yet support
> ES4, or one that supports both ES3 & 4, but treats "app/javascript" as
> ES3.
For a UA that does not support ES4, that would be a Reference Error
because the latter script would be rejected from being parsed because
of the content type, thus the name would not be defined
For a UA that supports both, it is not a problem - it's an ES3
[[Construct]] call. The ES3 internal [[Whatever]] functions are
translated into ES4 namespaced equivalents, AIUI.
(Another way to see it is that ES4 classical inheritance and
namespaces are a way to make things that ES3 uses for the host objects
available in user scripts as well.)
> Am I missing something?
Most of the ES4 added non-syntactic semantics would work perfectly
fine in ES3 as either internal behaviour or Host objects. ES3 code
obviously can't use new syntactic or expanded semantic behaviour from
ES4, but if the ES4 does that internally, then ES3 does not care.
--
David "liorean" Andersson
More information about the Es4-discuss
mailing list