Do Anonymous Exports Solve the Backwards Compatibility Problem?

Andreas Rossberg rossberg at google.com
Thu Dec 20 09:47:49 PST 2012


On 20 December 2012 14:17, Sam Tobin-Hochstadt <samth at ccs.neu.edu> wrote:

> We want to support *both* a syntax for 'import a module, and bind a
>  particular identifier to the single anonymous export' and a syntax for
> 'import a module, and bind an identifier to the module instance
> object'.  We could make these different syntaxes, but then (a) we need
> to similar syntaxes, which will confuse people when they use the wrong
> one and it doesn't work, and (b) you can't switch the implementation
> of a module from 'single export' to 'multiple export' without breaking
> clients.
>

Argument (a) does not convince me for two reasons. First, it very much
sounds like an argument for premature dumbdownification. Second, and more
importantly, I don't even believe the premise, namely that the potential
for confusion is greater than with overloading one syntax with two subtly
different meanings.

If you want to avoid confusion, don't introduce anonymous exports in the
first place. ;)  Seriously, no matter what syntax we pick for anonymous
imports, I'm sure that any confusion that ensues will be dwarfed by the
question why an export like

  export = {a: ..., b: ..., c: ...}

cannot be imported with

  import {a, b, c} from "..."

whereas it works for

  export {a: ..., b: ..., c: ...}

Would you risk a bet against this ending up among the Top 3 of ES module
WTFs? :)

Your point (b) is more interesting, at least in terms of a transition path
like you describe. But do we have any kind of evidence that such an
intermediate point on a transition path is particularly useful? And that it
will actually be relevant and/or workable for a significant number of
library implementers? Unless there is strong evidence, I'd be reluctant to
put some confusing hack into the language, eternally, that is only
potentially relevant for a limited time for a limited number of people.

I concur with Kevin's analysis that the emergence of singleton exports in
home-brewed JS module systems rather was a means than an end. Is there even
a single example out there of a language-level module system that has
something similar?

/Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121220/680fc9dd/attachment.html>


More information about the es-discuss mailing list