David Herman wrote:
> Hello!
> 
> I've updated the strawman proposals for static modules and 
> dynamic module loaders and would love to get feedback from 
> the es-discuss community.
> 
> * Static modules:
> 
>     http://wiki.ecmascript.org/doku.php?id=strawman:simple_modules
>
http://wiki.ecmascript.org/doku.php?id=strawman:simple_modules_examples

Hi David, and thanks for putting in this work. I have a few
questions below.

Cyclic dependencies
-------------------

>From the "Dependencies" section:

  | This allows cyclic dependencies between any two modules 
  | in a single scope

1) Is this to say that cycles are allowed, or not allowed, in 
other scenarios? (f ex remote or filesystem-loaded modules)

Import loads on demand
----------------------

>From the "Filesystem modules for offline ES" example:

  | // compiler/Lexer.js
  | module Lexer { ... }
  | ...
  | // Main.js
  | import compiler.Lexer.*;

2) Am I understanding this correctly as the module loader
fetching and registering Lexer.js "on demand" if not already
present in its registry mapping?

3) Is Lexer.js required to contain exactly one module
declaration that must match the filename, or otherwise an
exception is thrown?

4) Would this on demand loading functionality be present 
also on the web platform?

5) If so, would then the uses in main1 and main2 be equivalent
wrt binding MyLib names in the example below?

  // lib/MyLib.js
  module MyLib { export doStuff() ... }

  // main1.js
  import lib.MyLib.*;
  doStuff();

  // main2.js
  module wrapper = load "lib/MyLib.js";
  import wrapper.MyLib.*;
  doStuff();

"Importing" module level
------------------------

6) If I want to change the previous example to instead expose 
MyLib's names inside a MyLib module name, would I then do 
the following? :

  // main1.js
  module MyLib = lib.MyLib;
  MyLib.doStuff();

  // main2.js
  module wrapper = load "lib/MyLib.js";
  module MyLib = wrapper.MyLib;
  MyLib.doStuff();

Wrapper module on loaded scripts
--------------------------------

In the "Remote modules on the web (1)" example we have:

  | module JSON = load 'http://json.org/modules/json2.js';
  | alert(JSON.stringify({'hi': 'world'}));

7) Am I understanding correctly that this is pointing to a
plain script (without module decls) which is wrapped inside
the JSON module we specify?

8) Imagine a json2mod.js with an embedded:

  module JSON { ... }

which would result in:

  module JSON = load 'http://json.org/modules/json2mod.js';
  alert(JSON.JSON.stringify({'hi': 'world'}));

Is this assumption correct?

9) If so, what syntax could be used to avoid the extra wrapper
module at load? Could there f ex be a standalone load syntax 
that evaluates straight into the current scope:

  load 'http://json.org/modules/json2mod.js';
  alert(JSON.stringify({'hi': 'world'}));

(disclaimer: haven't thought much about implications of this)

MRLs
----

In the "Static module detection" example we have:

  | // compiler tries each in order
  | module JSON = load ('JSON' || 'http://json.org/modules/json2.js');

10) Does this syntax mix module identifiers and MRLs? (the 
'JSON' item looks very much like a pre-registered module in
the module registry?)

11) [Excuse my poor BNF] What is the +(',') for in:

  | ModuleDeclaration ::= 'module' Identifier '=' 'load' MRL+(',') ';'

Best regards
Mike Wilson

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

Reply via email to