excluding features from sloppy mode
brendan at mozilla.com
Sat Dec 29 13:22:26 PST 2012
Brendan Eich wrote:
> subtle mode mixtures,
I don't buy this one either. We have ES5 sloppy and strict, they mix
only statically, with well-defined rules based on "use strict"; (which
is not a readability trump card to throw, as discussed).
Any dynamic mixing is at the function call boundary.
Now, consider modules, classes, generators, and arrows:
* modules export functions, which are strict by definition under 1JS as
* classes define prototype methods (possibly static methods in future)
and possibly a constructor.
* generator functions are a kind of function.
* arrows are a kind of function.
In all these cases, we have static source delimiting, no mode mixing. In
all these cases, we have functions as the smallest units of abstraction.
These already may be strict or sloppy per ES5, at runtime.
Furthermore, all four bullets need definite semantics in ES6. We have to
say what poison pill properties, what rules for duplicate formals, etc.
are. There could be some "spec reuse" argument for factoring such that
strict mode decides these things, but with novel syntax in play, that is
not an overriding argument against strict-by-fiat.
Allen has already started spec'ing some of these things. He should weigh
in on the "spec reuse" situation, but my point here is that
strict-by-fiat-for-novel-bodies as I advocate does not create new
"subtle mode mixtures".
Yes, one won't see "use strict"; at the front of function bodies in
these four bulleted cases. So what? One often has to hunt thousands of
lines up, and match braces of module-pattern IIFEs, to know whether a
given function is in strict mode anyway.
More information about the es-discuss