On Wed, May 19, 2010 at 3:04 PM, David Herman <dher...@mozilla.com> wrote:

> If they want to share a utility module, you pull it out into a place that's 
> in scope for both ModA and ModB:
>
>    <script>
>    module ModUtils = load "http://acme.com/modutils.js";;
>    module ModA = load "http://acme.com/moda.js";;
>    module ModB = load "http://acme.com/modb.js";;
>    ...
>    </script>
>

Ahh - thanks for this.

So both the moda.js and modb.js source files can contain (for example):
ModUtils.myfunc();

And can import the exports of ModUtils:
import ModUtils.myfunc;
myfunc();


Also, a script author can configure which modules they will use:
For example use modules ModA and ModB - but not say - ModC and ModD.
<script>
module Acme {
  module ModUtils = load "http://acme.com/modutils.js";;
  module ModA = load "http://acme.com/moda.js";;
  module ModB = load "http://acme.com/modb.js";;
  // don't load the source files modc.js and modd.js - not used
}
Acme.ModA.myfunc();
Acme.ModB.myfunc2();
...
</script>

Is it correct that a module declaration within a script tag only has
scope within that script tag?

> I'm surprised to here you cite C as a precedent for modules, since C has no 
> module system.
That would be a surprise! No just the lexical concept.

--
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to