Module syntax

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Mon Jun 3 14:47:33 PDT 2013


On Mon, Jun 3, 2013 at 1:55 PM, Juan Ignacio Dopazo
<dopazo.juan at gmail.com>wrote:

> Now that it's been decided that braces are not a form of destructuring and
> the colon replaced with `as`, what's the benefit of using braces? Why not
> this previous proposal?
>
> import foo as foofoo from "foo";
>
> import "bar" as bar;
>

I'm predicting thousands of "why" here once it's shipped. Users will be
asking -- what the heck is going on here?

IM(h)O, it should be just:

import bar;

And that's it.

Below are some "syntax of my dreams" (not gonna bikeshead though):

Basic imports:

1. import foo; // imports exports of module foo and binds to foo; can be
used as foo.bar();
2. import "http://mysite.com/foo.js" as foo; // imports foo from external
source, can be done only via aliasing to bind name;
3. import default foo; // import the default expression from module foo.

Aliasing:

4. import foo as myFoo;
5. import "http://mysite.com/foo.js" as myFoo; // already mentioned

Import all bindings to the current ns:

6. import * from foo; // can be used then as bar(); baz();
7. import * from "http://mysite.com/foo.js; // the same

Import some of the methods:

8. import bar from foo; // imports only bar method from foo (w/ potential
syntax ambiguity and using {})
9. import {baz, bar} from foo; // ditto, two
10. import {baz: myBaz} from foo;
11. import bar from "http://mysite.com/foo.js";

Please, please, please -- would be awesome to NOT using string names (if of
course possible):

module foo {} // doesn't matter whether it's lexical or not, but foo is
just a name

module foo/bar {} // namespaced name, OK, can be module 'foo/bar' {}

P.S.: Although, I don't like bikesheading threads and think it should be
prepared well with arguments and all implementation details before
discussions.

Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130603/29da6a56/attachment-0001.html>


More information about the es-discuss mailing list