Minor questions on new module BNF

Yehuda Katz wycats at gmail.com
Tue Jun 4 07:55:32 PDT 2013


On Tue, Jun 4, 2013 at 6:29 AM, Kevin Smith <zenparsing at gmail.com> wrote:

>
>
>> Yep, agreed. (To be pedantic, it's not that it defers execution so much
>> as that it doesn't force execution.)
>>
>
> Can you explain?  I would naively expect for this:
>
>     // someModule
>     console.log("someModule");
>
>     // main
>     import "someModule";
>     console.log("main");
>
> when executing main, to output:
>
>     > someModule
>     > main
>

In general, expectations about side-effects that happen during module
loading are really edge-cases. I would go as far as to say that modules
that produce side effects during initial execution are "doing it wrong",
and are likely to produce sadness.

In this case, the `import` statement is just asking the module loader to
download "someModule", but allowing the app to move on with life and not
bother executing it. This would allow an app to depend on a bunch of
top-level modules that got executed only once the user entered a particular
area, saving on initial boot time.


>
> Thanks!
>
> { Kevin }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130604/3f1641d1/attachment.html>


More information about the es-discuss mailing list