On Nov 5, 2010, at 11:47 AM, Kris Zyp wrote:

[I rewrapped so this is readable, the lines were overlong and citing mangled 
them. /be]

>>> module myApp {
>>>   // load a template text
>>>   module Template = load "template.html" with "text-loader.js";
>>> 
>>>  // load some messages
>>>   module Messages = load "messages.json" with "i18n.js";
>>>   module OldModule = load "old-module.js" with "commonjs-loader.js";
>>> 
>>>   // use the default native harmony module loader
>>>   module NewShiny = load "a-harmony-module.js";
>>> ...
>>> };
>> 


> [samth here:]
>> But I don't think using the declarative syntax for this is a good idea - 
>> there's no static scope here; instead, there's arbitrary code execution and 
>> evaluation. Additionally, this makes everything synchronous.
>> 
> 
> Doesn't the default module loader get executed normally? Why do
> alternate module loaders change that?


> Why does it have to be synchronous, the module loader API is asynchronous?

The declarative syntax, as I pointed out earlier in this thread, is used to 
prefetch, so there is no violation of JS's run-to-completion model.

What you seem to be thinking, in your module myApp example, is that everything 
in between the nested module Template, module NewShiny, etc. lines is either 
run before those modules load (so cannot use anything loaded, so violates the 
JS execution model), or is automatically transformed into callbacks or even 
threaded, so that one could call OldModule.foo(); right after the module 
OldModule = ... line (btw, the "load" pseudo-keyword is being dropped), and not 
get a reference error.

But Harmony module syntax exists precisely to preserve the step at a time, no 
hidden threading or CPS'ing or event loop nesting, execution model, by enabling 
prefetching of static dependencies.

Dynamic dependencies require use of the module loader API, as Sam said. The 
static module declarations use the default module loader under the hood, but 
ahead of execution of the script that contains those module declarations. The 
script is parsed and the modules prefetched before execution starts.

/be

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to