Table of Contents


ECMAScript Edition 5 introduced a backwards-compatible syntax of the directive prologue with string-literal-expression-statement directives for pragmas. With Harmony, we are allowing the introduction of new syntax via versioning, so we should move towards a future-proof pragma syntax.


This spec proposes the introduction of a keyword use in place of the previous string-literal directives. In Harmony, the string literal form would no longer be recognized as special.

A hypothetical example is the old strawman lexical scope pragma:

use lexical scope;

While this spec does not propose any specific pragmas, its primary purpose is to create a syntactic space for future pragmas, i.e., for future-proofing.


The syntax of pragmas is designed to be very permissive, so that implementations may introduce custom pragmas.

UsePragma  ::= "use" PragmaItem ("," PragmaItem)* ";"
PragmaItem ::= PragmaWord+
PragmaWord ::= Keyword | Identifier


  • In Harmony, string literal statements are no longer recognized as prologue directives.

Open issues

  • semicolon insertion issues (no newline between PragmaItem keywords?)
  • more future-proofing for PragmaWord? allow literals? probably don’t want to allow operators, right?
  • best practices for non-standard prefixing? (e.g., “use moz widgets”)
  • A pragma that is unrecognized must be ignored? rejected?
harmony/pragmas.txt · Last modified: 2011/05/24 19:42 by dherman
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki