rossberg at google.com
Thu Dec 6 08:42:45 PST 2012
On 6 December 2012 17:33, Kevin Smith <khs4473 at gmail.com> wrote:
>> The downside is that it introduces a severe anomaly into the module
>> semantics (a module which actually has no instance). I could live with
>> this feature if we were to find a way to explain it in terms of simple
>> syntactic sugar on both the import and export side, but screwing and
>> complicating the semantics for minor syntactic convenience is not
>> something I am particularly fond of.
> What if this:
> export = "boo";
> Actually creates a static export with some exotic name, say __DEFAULT__ (for
> the sake of argument) and initializes it to the value "boo".
> And this form:
> import boo from "boo.js";
> Creates a binding to __DEFAULT__ in "boo.js", if it exists, or to the module
> instance of "boo.js" otherwise.
> Would that work as a desugaring?
I suggested something along these lines at some point in the past, but
there were some concerns with it that, unfortunately, I do not
remember. Maybe it can be resolved.
Note, however, that you still assume some hack in the semantics with
the "if it exists" part. To avoid that, you need to divorce the import
syntax from the naming-an-external-module syntax -- which I'd actually
prefer anyway, and which was the case in the previous version of the
More information about the es-discuss