Module linking (Was: The global object should not be the "global scope instance object")

Allen Wirfs-Brock allen at wirfs-brock.com
Mon Jan 30 11:45:33 PST 2012


On Jan 30, 2012, at 11:10 AM, Brendan Eich wrote:

>> Allen Wirfs-Brock <mailto:allen at wirfs-brock.com>
>> January 30, 2012 10:17 AM
>> On Jan 30, 2012, at 5:00 AM, Andreas Rossberg wrote:
>> 
>>> On 28 January 2012 02:08, Allen Wirfs-Brock<allen at wirfs-brock.com>  wrote:
>>>> I played around a bit to see if I could come up with a troublesome example
>>>> of the sort you may be thinking about.  What I came up with is the follow:
>>>> 
>>>> <script>
>>>> module a {
>>>>    import {x:y} from b;
>>> I think you wanted to say {y:x} here.
>> 
>> no, I think  {x:y}  means creating a binding for x that is linked to b.y
> 
> No, the binding name is in the property value position. This is why the shorthand works: import {x} from b; would bind local x to b.x.
> 
> Some find this "backwards" but it has to be this way -- the property name destructured from the RHS is on the left of : and the binding name is on the right. The shorthand helps in most cases, and backwards-sensitive people learn :-|.

Of source, and I've even written the spec. for destructuring with the ordering you intend.  Obviously, by backwards bit flipped sometime recently...

Allen




More information about the es-discuss mailing list