ES Modules: suggestions for improvement

Brendan Eich brendan at mozilla.org
Wed Jun 27 02:09:27 PDT 2012


David Bruant wrote:
> Le 27/06/2012 10:31, Brendan Eich a écrit :
>> David Bruant wrote:
>>> Le 26/06/2012 16:44, David Bruant a écrit :
>>>> Also relevant to this thread, post on the same topic by Isaacs 
>>>> (node.js lead) : http://blog.izs.me/post/25906678790/on-es-6-modules
>>> "Furthermore, |let| already gives us destructuring assignment. If a 
>>> module exports a bunch of items, and we want several of them, then 
>>> do |var {x,y,z} = import 'foo'| or some such."
>>> => Excellent idea. That combined with the single export idea reduces 
>>> the amount of new syntax to introduce.
>>
>> Declarations can nest under control flow constructs, but import or 
>> module dependencies must be prefetched. They're static.
>>
>>   if (some_rare_condition()) { let x = import "m"; ... }
>>
>> either always prefetches "m", which does not say what is meant;
> True.
> It could be considered to allow 'let x = import "m";' only at the top 
> level.
> But if it's the case, having a specific lexical form makes clearer 
> that it's a module import and not a regular assignment.

The other point people seem to miss about import as a special binding 
form is not just that it can be restricted grammatically to be 
control-insensitive by construction: it's that static export vs. import 
checking can be done to catch typos.

This is a significant point, but it's either missed or assumed 
insignificant. I think we should have a stand-up argument about it. 
Static module systems are static, in dependency prefetching, in binding, 
and in export vs. import checking.

/be


More information about the es-discuss mailing list