Nested modules clarification

Andreas Rossberg rossberg at google.com
Fri Jul 20 01:47:28 PDT 2012


On 20 July 2012 01:36, Erik Arvidsson <erik.arvidsson at gmail.com> wrote:

> On Thu, Jul 19, 2012 at 2:58 PM, ๏̯͡๏ Jasvir Nagra <jas at nagras.com> wrote:
> > Here's the modified test case from earlier:
> >
> > outer.js
> > ----------
> > module outer {
> >   let Object = {};
> >   export module inner = "http://m/inner.js";
> > }
> >
> > inner.js
> > ----------
> > Object.prototype.myMarker = 3;
> > assert( ({}).myMarker === 3 )
>
> A better inlining mechanism is:
>
> compiled.js
> --------------
> module $temp {
>   Object.prototype.myMarker = 3;
>   assert( ({}).myMarker === 3 )
> }
> module outer {
>   let Object = {};
>   export module inner = $temp;
> }
>
> This way multiple module foo = "http://m/inner.js" only leads to one
> module and you get less scope issues.
>

The main problem with this is that it changes the order of effects. Of
course, it is not recommended for a module body to have observable effects,
so maybe it's fine if an inliner ignores that issue and does not guarantee
semantic equivalence for such cases.

/Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120720/02113f17/attachment-0001.html>


More information about the es-discuss mailing list