Module Comments

Brendan Eich brendan at mozilla.org
Wed Dec 5 23:52:31 PST 2012


David Herman wrote:
> On Dec 5, 2012, at 7:16 PM, Kevin Smith<khs4473 at gmail.com>  wrote:
>
>> 1) "export" ExportSpecifierSet ("," ExportSpecifierSet)* ";"
>>
>> This rule seems too permissive.  It allows strange combinations like:
>>
>>      export x, { y: a.b.c, z }, { j, k }, * from "bloop";
>>
>> I think it would be better to flatten it out a little bit:
>>
>>      ExportDeclaration: "export" "{" ExportSpecifier ("," ExportSpecifier)* "}" ";"
>>      ExportDeclaration: "export" Identifier ("," Identifier)* ";"
>>      ExportDeclaration: "export" "*" "from" StringLiteral ";"
>
> Reasonable point, I'll think about that.

We do not so limit var, let, or const -- why should we limit export? Ok, 
it's a bit different (but then import is not, right?).

Style enforcement should not be wired into the grammar. If I want to write

   export {odd, even}, {nat: naturals};

why not?

Skipping 'as' reversal, that is a tough one! The export = ... special 
form does not suggest a better syntax, alas.

>> 4) Why was this form eliminated?
>>
>>      import x from "goo";  // Note lack of curlies!
>>
>> In an object-oriented application, we're often going to be importing a single thing (the class) from external modules.  So we may see long lists like this:
>>
>>      import { ClassA } from "ClassA.js";
>>      import { ClassB } from "ClassB.js";
>>      ....
>>      import { ClassZ } from "ClassZ.js";
>>
>> Removing the curlies for this simple case would seem like a win.
>
> Another fair point. I think it might've just been a refactoring oversight.

Cool, definitely want the plain identifier form, it's part of the 
binding (and destructuring) pattern language.

/be


More information about the es-discuss mailing list