Module Comments

Andreas Rossberg rossberg at
Mon Dec 10 01:55:41 PST 2012

On 10 December 2012 05:30, Kevin Smith <khs4473 at> wrote:
> OK, then suppose we have these two separate forms:
>     import x from "url"; // Bind x to the anonymous export, if defined,
> otherwise error
> and
>     import module x from "url"; // Bind x to the module instance
> In the vast majority of cases the "module" keyword above can be inferred
> correctly at link-time based on whether or not there is an anonymous export
> in the target module.
> If it were important for the user to disambiguate in those rare cases, and
> load the module instance instead of the anonymous export, then she could
> simply provide the optional "module" keyword.
> Does that work?

I consider such second-guessing of user intention, which can lead one
construct to mean completely different things, harmful. It makes code
less readable and more brittle. And again, it's a semantic hack,
making the language more complex. I just don't see why it would be
worth it, especially since with the right choice of syntax, the two
forms of declaration can easily be made equally concise.

What's so terrible about using different constructs for different
things that you want to avoid it?


More information about the es-discuss mailing list