"use strict"; prepended blindly to scripts in the wild
andrea.giammarchi at gmail.com
Sun Sep 19 04:03:19 PDT 2010
sorry I could not find a way to inject myself in the original thread.
Dmitry has very valid points there and I have not seen a concrete solution
to this problem so here I am with a couple of proposals.
#1 First Script Rule
I do believe, since there is no "use quirks" directive, that once we put a
"use strict" in the global scope and in the very first script, we would like
to be sure the whole thingy uses strict.
In few words, if I am the author of the application/webpage/whatever I
should be the one responsible for strictness.
Moreover, if strict is messed up with non strict we may have horrible side
effects so ... "all strict" when global strict is set sounds reasonable
while if we do not want "all strict" we should use our own closure and most
of the libraries out there do already.
#2 Strict Label
JS labels have been there since ages so I wonder if something like this
would make sense:
// optionally with a var statement
// for all variables used in this
// strict context
var i = 123;
// etc etc ...
// optionally made semantic
// via const and a while
// const could be a var as well
const valid = true;
var j = 123;
// but we don't need const or var
// your stuff here
Labels would be compatible and the concatenation of scripts won't be a
problem, we always have a proper block when we wont to do stuff in a strict
way where "strict" should be the reserved label name for "use strict"
What do you think?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss