> Thought looking at the syntax section it seems that `import Math;` isn't
> valid and instead you do it as `module Math = Math`. Why not use import here
> as well? My first instinct here is `module` is for defining a module and
> `import` is importing it - instead `module` serves a dual function.
That's not quite right; 'module' is for creating a module *binding*. I.e., all
the forms start with 'module m' and create a lexical binding of 'm' to a
statically known module.
> Is there any reasoning for this behaviour that I might have missed?
The idea is that 'module' creates module bindings and 'import' creates value
bindings. So you can create a statically bound module binding via:
module M = MyLib.Math; // M is now a module binding that aliases MyLib.Math
import M.*; // import all bindings from MyLib.Math
whereas 'import' always creates a value binding:
import MyLib.Math; // Math is now a value binding
import Math.*; // error: Math is not a module binding
Since we are allowing dynamic reflection of modules, a goal of this proposal is
to keep the distinction between static module bindings and dynamic module
values as firm as possible, while still making it as convenient as possible to
reflect modules as values.
Dave
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss