excluding features from sloppy mode
herby at mailbox.sk
Sun Dec 30 02:42:03 PST 2012
Domenic Denicola wrote:
>> From: es-discuss-bounces at mozilla.org
>> [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Brendan Eich
>> Sent: Sunday, December 30, 2012 00:06
>> by yoking ES6 feature adoption to strict mode adoption, you
>> multiply risks and reduce ES6 adoption.
> I'd like to lend a little bit of defense to Kevin's ideas here.
> Namely, it seems easy to me to imagine the following:
> - "Oh cool, ES6 is in $MY_FAVORITE_JS_ENVIRONMENT!"
> - "Awesome lemme insert some arrow functions to clean up all these map and filter arguments"
> - "What's that, Mr. Compiler? You won't let me use arrow functions unless I put 'use strict' at the top of my file?"
> - "OK, whatever, that seems lame, but arrow functions are worth it."
> This is of course predicated on the code in question not being
> affected by the breaking changes of strict mode, which is probably
> true of most code written by early adopters today.
> To be clear, there's obviously a lot of subtle issues here, as
> Brendan has pointed out. I do find it somewhat unlikely though, that
> *if* strict mode was required for anything ES6-ish, people would give
> up their new toys rather than point a pragma at the top of their
The old conforming sloppy code will work.
The new must be strict to use new things.
But the new things _are_ valuable. Wanting 'use strict' (or module, or
class) should not be an issue for people writing new code. Nor, imho,
for people redesigning big bunches of old code. The only losers of this
reform are people with old codebase wanting to clean it using better new
constructs but their boss prohibits them using 'use strict'. And even
for them, class is giving opportunity of incremental progress.
I would solve the little issue of "class can be of very little
granularity when using class expressions" by using only standalone class
definitions* as implicitly strict (and using class expression in sloppy
code would just end up with "new features only in strict mode" error).
> (Although, as I write that last sentence, I realize this isn't much
> different than suggested `use version 6` :-/)
But it isn't. So in fact no additional mode. That's important. :-)
* If there are "module expressions", disallowing them, too.
More information about the es-discuss