Module Comments

Nathan Wall nathan.wall at live.com
Sun Dec 9 06:07:16 PST 2012


I see my previous email did not format well in the archive. I'm retrying this. (Could someone please give me some formatting tips?)
Nathan

> The problem is that imports are not normal variable assignments. They
> do not copy values, like normal destructuring, they are aliasing
> bindings! If you were to allow arbitrary expressions and patterns,
> then this would imply aliasing of arbitrary object properties. Not
> only is this a completely new feature, it also is rather questionable
> -- the aliased location might disappear, because objects are mutable.


Could it be structured so that using `export` directly on a variable exported the alias, while using `import { x: [ a, b ] } from A; ` was basically just sugar for `import { x } from A; let [ a, b ] = x;` so that a and b copied not aliased?

Example:

    module A {        export let x = { a: 1, b: 2 };        export function f() { x = { a: 3, b: 4 }; };    }

    ...

    import { x: { a, b }, f } from A;    f();    print(a); // 1    print(b); // 2

    ...

    import { x, f } from A;    f();    print(x.a); // 3    print(x.b); // 4
 		 	   		   		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121209/abf7c98f/attachment-0001.html>


More information about the es-discuss mailing list