On Mon, May 17, 2010 at 4:07 PM, David Herman <[email protected]> wrote:

> [snip] For example, consider:
>
>    module M = load "http://example.com/foo.js";;
>    module N = load "http://example.com/foo.js";;
>
> These two modules are loaded from the exact same MRL, but the module system 
> treats them as two completely separate, independent modules. (Even custom 
> module loaders shouldn't be able to change this fact, since all they can do 
> is deliver the bits of a module resource.)
>
> The reason for this is that on the web, there's just no way to know that two 
> URL's point to the "same" resource-- fetching the bit-for-bit-same URL even 
> microseconds apart can result in completely different data, since web servers 
> are free to deliver whatever they want. So the module loading semantics is 
> resolutely non-clever about interpreting MRL's.
>
> Dave
>
>

That's surprising. Within a moduleloader I would have thought that
same url meant the same static module. Across moduleloaders maybe not.

For the following scenario:
<script>
module ModA = "http://acme.com/moda.js";;
module ModB = "http://acme.com/modb.js";;
... source
</script>

Both ModA and ModB use a utility module - that is the moda.js and
modb.js files both contain:
module ModUtils = "http://widgets.com/modutils.js";;

I would have guessed that ModA and ModB are using the exact same
static utility module. Firstly for efficiency - "hey this source has
been fetched and compiled already".

But also, simple modules seem like 'traditional' modules. That is, if
a top level variable is declared in a C source file, that variable
occurs once in the resulting compiled image/program. Thus the source
files (modules) author can reason about the (shared state) of the
variable.

However, if an ES module source can be declared multiple times (within
a moduleloader) - doesn't it become harder for the author of the
module to reason about a top level variable. If multiple instance of a
module variable are required - then maybe an object should be used.

Also, it seems unlikely that a new module source would be generated by
a server within the context of a moduleloader fetching/compiling
source. Maybe the rule should be - first source fetched for a url is
the source used for subsequent module references.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to