On Tue, Jun 4, 2013 at 6:29 AM, Kevin Smith <zenpars...@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 }
>
>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to