A few more thoughts...

On Mon, Jun 16, 2014 at 1:41 PM, Jasper St. Pierre <[email protected]>
wrote:

>
> On Mon, Jun 16, 2014 at 1:22 PM, Rick Waldron <[email protected]>
> wrote:
>
>>
>> On Mon, Jun 16, 2014 at 1:05 PM, Calvin Metcalf <[email protected]
>> > wrote:
>>
>>> e.g. something like
>>> https://gist.github.com/calvinmetcalf/9252f41bf6e3c8b4add7
>>>
>>
>> re:
>>
>>   let { foo, bar } = import "library";
>>
>> Ignoring the UnaryExpression ambiguity, what happens here:
>>
>>
>> // library.js
>> export const MAX_VALUE = 1023;
>>
>>
>> // program.js
>> let { MAX_VALUE } = import "library";
>> MAX_VALUE = 1;
>>
>
> Seems like a straightforward thing to me. "let" creates a local binding
> for the scope of the file. It shouldn't be anything different from:
>
>     function importMyLibrary() {
>         let module = import "library";
>

When does the actual import operation take place? Can I assume that it
takes place only after `importMyLibrary` is called? If so, then `import`
will block while awaiting IO—this is "maybe" ok for non-browser JS
runtimes, but not ok for the browser.


>         return module;
>     }
>
>     let { MAX_VALUE } = importMyLibrary();
>     MAX_VALUE = 1;
>
> Or:
>
>     function importMyLibrary() {
>         let module = import "library";
>         let MAX_VALUE = module.MAX_VALUE;
>         return { MAX_VALUE: MAX_VALUE };
>     }
>

Yes that reassignment works, but it would be a serious flaw (potentially a
security hazard) if the language just assumed that was was the desired
behaviour.

Rick
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to