On Apr 18, 2010, at 10:00 AM, Peter van der Zee wrote:

This could be fixed by some kind detection scheme for these directives.

You can't detect new syntax except by embedding it in a string and eval'ing the string inside a try/catch.


You can add the directive and detect whether it has been activated at a later point, can't you?

If you mean "use strict"; then yes, you can add that to a function and detect the lack of its effect in pre-ES5 (or buggy ES5) implementations.

If you mean new syntax, not a pragma hidden in an otherwise-useless strict expression-statement, then the syntax error exception will stop parsing at the point of new syntax. To detect the lack of successful parsing you'd have to write a later <script> or second compilation unit of some kind, and try to deduce that the first unit did not compile successfully because the new syntax was not recognized.

But this is onerous and error prone. Thus the opt-in versioning idea based on RFC 4329, at least for code that needs the new syntax.

/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to