2010/9/9 Dmitry Soshnikov <dmitry.soshni...@gmail.com>: > On Tue, Sep 7, 2010 at 9:35 PM, Brendan Eich <bren...@mozilla.com> wrote: >> >> On Sep 7, 2010, at 10:28 AM, Boris Zbarsky wrote: >> >> > On 9/7/10 1:21 PM, Brendan Eich wrote: >> >> See, e.g., https://bugzilla.mozilla.org/show_bug.cgi?id=593963 -- but >> >> this is not the first instance. Previously: >> >> https://bugzilla.mozilla.org/show_bug.cgi?id=579119. >> > >> > The latter wasn't blind. It was just a site concatenating a bunch of >> > third-party scripts together, and one of the third-party scripts >> > (correctly) >> > using strict.... So that one is totally Amazon's flub, imo. >> >> Thanks -- this clarifies things, and makes me worry about more of the >> same. >> >> "Blind concatenation" is a feature as much as a bug in the history of JS. >> Combined with script inline content moving out to src= URL-named convent, it >> is how we end up with Unicode BOMs and <!-- pseudo-comments in the middle of >> files. >> > > Currently, a site may normally concatenate 3rd-party libs with "use strict" > at the global level. The technique is the same as with forgotten semicolon > -- just to put an empty statement at the beginning of the end file.
A forgotten semicolon at the end of the first concatenated file can be a problem though. Consider the concatenation of (function () { foo(); })() and (function () { bar() })() Independently loaded, you get a call to foo and a call to bar. Concatenated, you get a call to foo and a TypeError complaining that undefined is not a function. So in both cases naive concatenation introduces subtle bugs by changing the meaning of the first or lass statement in a compilation unit. > Thus the site's combined file won't be globally strict, however since a lib > is tested before a production release (at least I hope so ;), then the lib's > code should pass the strictness, and therefore, a "use strict" may be even > removed from the lib's file. However, if not to remove, then an empty > statement is enough. > > ;/*1st lib*/"use strict";eval = 10;/*2st lib*/"use > strict";arguments=20;/*our code*/ > > Dmitry. > >> >> /be >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss > > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss