ES5 Implementation Best Practice

Don't Pollute Strict Mode with Non-standard Declaration Forms

What

In strict mode code:

  • Do not implemented any non-standard statements or declarations that begin with the keywords const or let.
  • Do not allow a FunctionDeclaration to occur in a Statement context.

Why

The current TC39 plan of record is to include such constructs as standard strict mode features in the next edition of the ECMAScript standard. If ES5 implementations include such features but implement them inconsistently it creates interoperability problems for JavaScript programmers. It would also make it impossible for future ECMAScript editions to standardize such features in a manner that did not invalidate some existing implementations or code.

Elaboration

Historically many ECMAScript implementations have included extensions of this sort. In some cases (for example FunctionDeclarations in Statment contexts) the details of the extensions differ enough between implementations that there is little or no useful intersection semantics among the various implementations of a seemingly common extension.

ES5 strict mode, is a completely new mode of the language for which no usage currently exists. This means that it can be a clean foundation for the future evolution of the lanaguage. For this reason, TC39’s plan of record is limit most future feature additions to operating in strict mode. However, this plan may not work if ES5 implementations pollute strict mode with inconsistent and incompatable implementations of extensions that are likely to conflict with future standardization efforts.

TC39 already has tentative agreement for including const, let, and statement level function declarations in the next edition of ECMAScript. For this reason, ES5 implementation should avoid including these features in strict mode until complete specifications of these features have been written and approved by TC39.

 
conventions/no_non_standard_strict_decls.txt · Last modified: 2010/05/27 17:45 by allen
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki