Nested modules clarification

๏̯͡๏ Jasvir Nagra jas at nagras.com
Tue Jul 17 21:17:18 PDT 2012


Module Rationale (
http://wiki.ecmascript.org/doku.php?id=harmony:modules_rationale) suggests
that

   - Modules can be nested.

This makes it convenient to modularize code cheaply, without having to
create separate files. It is also consistent with the semantics that file
top-level is implicitly a module but can contain sub-modules. Finally, it
makes refactoring work well: code separated into modules can itself be
separated into a new parent module.


However, Module Semantics (
http://wiki.ecmascript.org/doku.php?id=harmony:modules_semantics) suggests
that each inline module declaration introduces a fresh scope.  Given this,
I am trying to understand whether there is any difference in semantics
between nested rather than sibling modules.

For example, is there any semantic difference between the following:

module widgets {
    export module button { ... }
    export module alert { ... }
    export module textarea { ... }
    ...}import { messageBox, confirmDialog } from widgets.alert;

and

module widgets.button { ... }
module widgets.alert { ... }
module widgets.textarea { ... }
...
 import { messageBox, confirmDialog } from widgets.alert;


...other than the change to the grammar that module name can now contain a
".".

--
Jasvir Nagra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120717/c2b8ee17/attachment.html>


More information about the es-discuss mailing list