Mark S. Miller (2014-01-24T20:22:48.000Z)
Assuming the current system for a moment, and discussing only conventions:

It is true that a "use strict" at the top of every *.js file does have
the virtue of making it clear, both to tools and humans, that the
remainder is strict code, even in one doesn't know if the file is to be
loaded as a module or a script. Historically, we've recommended
against a bare "use strict" at the top of script files
<
http://wiki.ecmascript.org/doku.php?id=conventions:avoid_strictness_contagion
>,
in order to avoid the concatenation hazard. Instead, we recommend that
script files have an outer strict IIFE. This still seems sensible when
there's genuine ambiguity about whether it is a module or a script.

OTOH, if the author knows it is a module and simply wants to
disambiguate to tools that it is strict, then the author knows there's
no concatenation hazard and a bare "use strict" at the top would be
fine. And, of course, if there are any export or import statements in
there, then it cannot be a script, and it cannot be contained in an IIFE.

Btw, the conventional name for the opposite of strict is "sloppy"
rather than "loose".


On Fri, Jan 24, 2014 at 8:48 AM, John Lenz <concavelenz at gmail.com> wrote:

> For static language parsers there seems to be a bit of a dilemma with ES6
> modules.  I would appreciate a correct or hint.
>
> Here is my understanding:
>
>   - standard scripts as we know them today will parse in the browser as
> "loose" code
>   - scripts with the standard "use strict" will parse as "strict" with
> access to all ES6 goodness
>   - scripts loaded as modules will parse as "strict" even without the "use
> strict" annotation.
>
> Is this true?  If so, it seems like a tooling hazard and "use strict" on
> modules should at least be the encouraged convention.
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140124/deb01d55/attachment.html>
domenic at domenicdenicola.com (2014-01-31T21:18:17.707Z)
Assuming the current system for a moment, and discussing only conventions:

It is true that a "use strict" at the top of every *.js file does have
the virtue of making it clear, both to tools and humans, that the
remainder is strict code, even in one doesn't know if the file is to be
loaded as a module or a script. Historically, we've recommended
against a bare "use strict" at the top of script files http://wiki.ecmascript.org/doku.php?id=conventions:avoid_strictness_contagion,
in order to avoid the concatenation hazard. Instead, we recommend that
script files have an outer strict IIFE. This still seems sensible when
there's genuine ambiguity about whether it is a module or a script.

OTOH, if the author knows it is a module and simply wants to
disambiguate to tools that it is strict, then the author knows there's
no concatenation hazard and a bare "use strict" at the top would be
fine. And, of course, if there are any export or import statements in
there, then it cannot be a script, and it cannot be contained in an IIFE.

Btw, the conventional name for the opposite of strict is "sloppy"
rather than "loose".