No subject

Thu Feb 11 18:09:36 PST 2010

  | // 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.*;

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

"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;

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

Wrapper module on loaded scripts

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

  | module JSON = load '';
  | 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 '';
  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 '';
  alert(JSON.stringify({'hi': 'world'}));

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


In the "Static module detection" example we have:

  | // compiler tries each in order
  | module JSON = load ('JSON' || '');

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

More information about the es-discuss mailing list