Nested modules clarification

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


On Tue, Jul 17, 2012 at 11:21 PM, David Herman <dherman at mozilla.com> wrote:

> On Jul 17, 2012, at 9:17 PM, ๏̯͡๏ Jasvir Nagra wrote:
>
> However, Module Semantics (
> http://wiki.ecmascript.org/doku.php?id=harmony:modules_semantics)
> suggests that each inline module declaration introduces a fresh scope.
>
>
> As in, a fresh *nested* scope.
>

Ah that was definitely not clear to me from reading the spec or the
examples.  What outer bindings can be referred to - any lexically scoped
variables or just other module definitions?

> Given this, I am trying to understand whether there is any difference in
> semantics between nested rather than sibling modules.
>
>
> Yes. They can refer to outer bindings.
>
> 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
> ".".
>
>
> Well, you didn't tell us what the semantics of your new syntax is. :) But
> it seems to suggest that anyone anywhere could add to a module. The
> declarative syntax is meant to keep the exports of a module local to its
> body. Allowing anyone anywhere to extend a module runs counter to the idea
> of modularity.
>

I wasn't suggesting new semantics - just trying to clarify what I thought
the draft was saying ie. that a completely fresh scope was created.  If
that were the case, nesting wouldn't buy you much other than
perhaps syntactical organization.


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


More information about the es-discuss mailing list