Modules: Curly Free

Andreas Rossberg rossberg at google.com
Tue Apr 16 12:36:15 PDT 2013


On 16 April 2013 20:36, David Herman <dherman at mozilla.com> wrote:
> On Apr 16, 2013, at 10:20 AM, Andreas Rossberg <rossberg at google.com> wrote:
>
>> On 16 April 2013 18:55, David Herman <dherman at mozilla.com> wrote:
>>> I'm gonna bite the bullet here and tempt the bikeshedding demons by making an incremental suggestion for a syntax for anonymous import/export that adds to your syntax.
>>>
>>>    export default f(1, 2, 3);        // creates anonymous export by evaluating RHS expression
>>>
>>>    import default as foo from "foo"; // binds the anonymous export from module "foo" to variable foo
>>
>> OK, you asked for it.
>
> Indeed... :-}
>
>> How exactly is that superior to
>>
>>  export let it = f(1, 2, 3)
>>
>>  import it as foo from "foo"
>>
>> which is both shorter and does not need any extension to the syntax at all?
>
> Because character count is not the only measure of clarity. And requiring a naming convention imposes standardization costs. We're the standards body!

I don't understand. Are you saying that it has a higher cost to
standardize a trivial convention than it is to standardize additional
ad-hoc syntax?

> Not only that, but there's also the problem of interoperability with existing code (AMD, NPM, etc) that uses the "single dynamic export" idiom.

Sure, but that's probably equi-distant from both solutions, i.e.,
neither makes that easier or harder than the other. At least I don't
see how.

/Andreas


More information about the es-discuss mailing list