ES6 doesn't need opt-in

Brendan Eich brendan at mozilla.com
Mon Jan 2 22:19:02 PST 2012


[Dave has been traveling, hope it's ok for me to jump in. /be]

On Jan 2, 2012, at 6:07 AM, Andreas Rossberg wrote:

> In other words, I think the main points of your proposal can
> essentially be rephrased to:
> 
> 1) Rename "use version 6" to "use module".
> 2) Allow module declarations in classic mode.

[Replying to (1) and (2) here:]

Not just module declarations -- all new syntax that is not backwards-incompatible: destructuring, rest/spread, for/of ,generators, comprehensions, generator expresions, quasiliterals, more.


> 3) Make every module body start with an implicit "use module".

That's not right: use module; in a pragma turns the enclosing block or body into a module {...}, in a macro-like way. Then if the module {...} is illegal in the given context (i.e., not nested immediately in another module's body), you get the same error you'd get trying to write, e.g.,

 if (cond) { module { /* stuff */ } }


> 4) Keep the semantics of the top-level scope unaltered, even in
> presence of a top-level "use module".

No, see above: that turns the verbatim top level into the ... part of module {...}.


> I'm fine with (1) to (3), but (4) seems to be a separate design choice.

With what I wrote above in mind, what do you think now?

/be


More information about the es-discuss mailing list