Re: Module Comments

2012-12-10 Thread Andreas Rossberg
On 10 December 2012 05:30, Kevin Smith khs4...@gmail.com 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

Re: Module Comments

2012-12-10 Thread Kevin Smith
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

Re: Module Comments

2012-12-09 Thread Andreas Rossberg
On 9 December 2012 02:10, Kevin Smith khs4...@gmail.com wrote: So if you didn't set the anonymous binding in some module x.js, what would this do: import x from x.js; Would x be bound to the module instance or would we get a binding error? Since it is just sugar, and supposed to be

Re: Module Comments

2012-12-09 Thread Andreas Rossberg
On 9 December 2012 03:51, Domenic Denicola dome...@domenicdenicola.com wrote: From: Andreas Rossberg [mailto:rossb...@google.com] On 6 December 2012 16:44, Domenic Denicola dome...@domenicdenicola.com wrote: For the record, here's the idea Yehuda and I worked out:

RE: Module Comments

2012-12-09 Thread Nathan Wall
The problem is that imports are not normal variable assignments. They do not copy values, like normal destructuring, they are aliasing bindings! If you were to allow arbitrary expressions and patterns, then this would imply aliasing of arbitrary object properties. Not only is this a

RE: Module Comments

2012-12-09 Thread Nathan Wall
I see my previous email did not format well in the archive. I'm retrying this. (Could someone please give me some formatting tips?) Nathan The problem is that imports are not normal variable assignments. They do not copy values, like normal destructuring, they are aliasing bindings! If you

Re: Module Comments

2012-12-09 Thread Andreas Rossberg
On 9 December 2012 15:04, Nathan Wall nathan.w...@live.com wrote: The problem is that imports are not normal variable assignments. They do not copy values, like normal destructuring, they are aliasing bindings! If you were to allow arbitrary expressions and patterns, then this would imply

RE: Module Comments

2012-12-09 Thread Nathan Wall
Yeah, that makes sense. I agree. Thanks. Nathan On 9 December 2012 15:04, Nathan Wall nathan.w...@live.com wrote: The problem is that imports are not normal variable assignments. They do not copy values, like normal destructuring, they are aliasing bindings! If you were to allow

Re: Module Comments

2012-12-09 Thread Herby Vojčík
Domenic Denicola wrote: -Original Message- From: Andreas Rossberg [mailto:rossb...@google.com] Sent: Thursday, December 6, 2012 11:31 On 6 December 2012 16:44, Domenic Denicola dome...@domenicdenicola.com wrote: For the record, here's the idea Yehuda and I worked out:

Re: Module Comments

2012-12-09 Thread Kevin Smith
Since it is just sugar, and supposed to be equivalent to the expansion, you (fortunately) would get an error (statically). 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

Re: Module Comments

2012-12-08 Thread Kevin Smith
So if you didn't set the anonymous binding in some module x.js, what would this do: import x from x.js; Would x be bound to the module instance or would we get a binding error? For module naming, we'd need to have a different syntax. In earlier versions of the proposal that was module

RE: Module Comments

2012-12-08 Thread Domenic Denicola
-Original Message- From: Andreas Rossberg [mailto:rossb...@google.com] Sent: Thursday, December 6, 2012 11:31 On 6 December 2012 16:44, Domenic Denicola dome...@domenicdenicola.com wrote: For the record, here's the idea Yehuda and I worked out:

Re: Module Comments

2012-12-07 Thread Andreas Rossberg
On 6 December 2012 17:54, Kevin Smith khs4...@gmail.com wrote: 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

Re: Module Comments

2012-12-07 Thread Russell Leggett
On Thu, Dec 6, 2012 at 1:46 PM, Brendan Eich bren...@mozilla.org wrote: David Herman wrote: Cool, definitely want the plain identifier form, it's part of the binding (and destructuring) pattern language. Well, the thing is it isn't consistent with the destructuring meaning: dropping the

RE: Module Comments

2012-12-07 Thread Nathan Wall
Feel free to suggest alternatives, but forgive me if I'm not willing to respond to every opinion on this one. :} How about: import ga as ga; to import the whole module, and import ga as { foo, bar }; to import just parts of the module. I feel like this makes a lot of sense, and

Re: Module Comments

2012-12-06 Thread David Herman
On Dec 5, 2012, at 11:52 PM, Brendan Eich bren...@mozilla.org wrote: ExportDeclaration: export { ExportSpecifier (, ExportSpecifier)* } ; ExportDeclaration: export Identifier (, Identifier)* ; ExportDeclaration: export * from StringLiteral ; Reasonable point, I'll think about

Re: Module Comments

2012-12-06 Thread Jussi Kalliokoski
On Thu, Dec 6, 2012 at 8:25 AM, David Herman dher...@mozilla.com wrote: On Dec 5, 2012, at 7:16 PM, Kevin Smith khs4...@gmail.com wrote: 1) export ExportSpecifierSet (, ExportSpecifierSet)* ; This rule seems too permissive. It allows strange combinations like: export x, { y:

Re: Module Comments

2012-12-06 Thread Claus Reinke
Well, the thing is it isn't consistent with the destructuring meaning: dropping the curlies here means extracting a single export (aka property), which is not what it means in destructuring assignment/binding anywhere else. But that said, the convenience may well still trump the inconsistency.

Re: Module Comments

2012-12-06 Thread Sam Tobin-Hochstadt
On Thu, Dec 6, 2012 at 1:25 AM, David Herman dher...@mozilla.com wrote: On Dec 5, 2012, at 7:16 PM, Kevin Smith khs4...@gmail.com wrote: 2) Do we need `export *;`? I don't see the point of exporting every declaration in the current module scope. If the programmer wants to export a bunch of

Re: Module Comments

2012-12-06 Thread Kevin Smith
Summaries with comments: 1) export ExportSpecifierSet (, ExportSpecifierSet)* ; Brendan pointed out that other binding forms allow lists (including the import form), so why not this one? I actually didn't realize that lists are allowed with import: ImportDeclaration ::= import

Re: Module Comments

2012-12-06 Thread Erik Arvidsson
On Thu, Dec 6, 2012 at 9:42 AM, Kevin Smith khs4...@gmail.com wrote: Dave responded by pointing out that we don't want from to have overloaded semantics. I actually think this form has potential, because it further aligns import with the other binding forms: var a = x; var { b } =

Re: Module Comments

2012-12-06 Thread Axel Rauschmayer
+1 Compared to Node.js, I love ES6 exports, but Node.js module imports are easier to understand. Claus’ suggestion would make `import` similar to `let` and people could basically think of modules as objects. On Dec 6, 2012, at 10:41 , Claus Reinke claus.rei...@talk21.com wrote: Well, the

RE: Module Comments

2012-12-06 Thread Domenic Denicola
-discuss-boun...@mozilla.org [es-discuss-boun...@mozilla.org] on behalf of Erik Arvidsson [erik.arvids...@gmail.com] Sent: Thursday, December 06, 2012 09:54 To: Kevin Smith Cc: es-discuss Subject: Re: Module Comments On Thu, Dec 6, 2012 at 9:42 AM, Kevin Smith khs4...@gmail.commailto:khs4

Re: Module Comments

2012-12-06 Thread Andreas Rossberg
On 6 December 2012 15:42, Kevin Smith khs4...@gmail.com wrote: 5) Dynamic exports via `export = ?` could make interop with existing module systems easier. But how does that work? Dave gave an outline. I'm liking this. What are the downsides, if any? The downside is that it introduces a

Re: Module Comments

2012-12-06 Thread Yehuda Katz
import. -- *From:* es-discuss-boun...@mozilla.org [es-discuss-boun...@mozilla.org] on behalf of Erik Arvidsson [erik.arvids...@gmail.com] *Sent:* Thursday, December 06, 2012 09:54 *To:* Kevin Smith *Cc:* es-discuss *Subject:* Re: Module Comments On Thu, Dec 6

Re: Module Comments

2012-12-06 Thread Andreas Rossberg
On 6 December 2012 16:44, Domenic Denicola dome...@domenicdenicola.com wrote: For the record, here's the idea Yehuda and I worked out: https://gist.github.com/1ab3f0daa7b37859ce43 I would *really* appreciate if people read it (it's easy reading, I promise!) and incorporated some of our

Re: Module Comments

2012-12-06 Thread Kevin Smith
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

Re: Module Comments

2012-12-06 Thread Andreas Rossberg
On 6 December 2012 17:33, Kevin Smith khs4...@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

Re: Module Comments

2012-12-06 Thread Matthew Robb
What about trying it the other way, flip everything. import foo as bar; import foo as { baz } On Thu, Dec 6, 2012 at 8:42 AM, Andreas Rossberg rossb...@google.comwrote: On 6 December 2012 17:33, Kevin Smith khs4...@gmail.com wrote: The downside is that it introduces a severe anomaly into

Re: Module Comments

2012-12-06 Thread Andreas Rossberg
On 6 December 2012 17:46, Matthew Robb matthewwr...@gmail.com wrote: What about trying it the other way, flip everything. import foo as bar; import foo as { baz } Hm, I don't understand. What would that solve? /Andreas ___ es-discuss mailing list

Re: Module Comments

2012-12-06 Thread Matthew Robb
Well the argument being that as it stands it's inconsistent having the identifier on the RHS for import from and LHS in import as: import baz from foo; import foo as foo; I'm just throwing out simple options for solving that inconsistency. Possibly even thinking about them as declarations makes

Re: Module Comments

2012-12-06 Thread Kevin Smith
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 proposal.

Re: Module Comments

2012-12-06 Thread Brandon Benvie
Every module instance has a $DEFAULT export binding. Normally, it is set to the module instance itself. `export = ?` overrides the value of that binding. `import x from y` binds $DEFAULT in y to x. Maybe? That would be how Node.js does. For those unfamiliar with how it works, it's

Re: Module Comments

2012-12-06 Thread Brendan Eich
David Herman wrote: Cool, definitely want the plain identifier form, it's part of the binding (and destructuring) pattern language. Well, the thing is it isn't consistent with the destructuring meaning: dropping the curlies here means extracting a single export (aka property), which is not

Re: Module Comments

2012-12-05 Thread Herby Vojčík
David Herman wrote: On Dec 5, 2012, at 7:16 PM, Kevin Smithkhs4...@gmail.com wrote: 3) I'm just OK with as. Note that it inverts the position of the string and the binding: import { x } from goo; import ga as ga; Which makes it harder to read when you have a bunch of imports

Re: Module Comments

2012-12-05 Thread David Herman
On Dec 5, 2012, at 10:41 PM, Herby Vojčík he...@mailbox.sk wrote: import x from goo; Already taken. You can't use one syntax to mean two things. import ga for ga; That doesn't have any correspondence to its meaning in English. import x from goo; That's identical to your first suggestion.

Re: Module Comments

2012-12-05 Thread Herby Vojčík
David Herman wrote: On Dec 5, 2012, at 10:41 PM, Herby Vojčíkhe...@mailbox.sk wrote: import x from goo; Already taken. You can't use one syntax to mean two things. I don't. These were included to show the two syntaxes (existing from and proposed instead-of-as grouped together; to see

Re: Module Comments

2012-12-05 Thread Matthew Robb
I don't see why you can't treat it like this: import local accessor from resource import ga from ga; If you want to import specific exports then use curlies or dot notation import ga.foo from ga; import { foo } from ga; On Wed, Dec 5, 2012 at 11:05 PM, Herby Vojčík he...@mailbox.sk wrote:

Re: Module Comments

2012-12-05 Thread David Herman
On Dec 5, 2012, at 11:05 PM, Herby Vojčík he...@mailbox.sk wrote: import x from goo; Already taken. You can't use one syntax to mean two things. I don't. These were included to show the two syntaxes (existing from and proposed instead-of-as grouped together; to see how they look mixed).

Re: Module Comments

2012-12-05 Thread David Herman
On Dec 5, 2012, at 11:09 PM, Matthew Robb matthewwr...@gmail.com wrote: I don't see why you can't treat it like this: import local accessor from resource import ga from ga; We really don't want `from` to be dual-purposed to sometimes mean the whole module itself, and sometimes extracting

Re: Module Comments

2012-12-05 Thread Brendan Eich
David Herman wrote: On Dec 5, 2012, at 7:16 PM, Kevin Smithkhs4...@gmail.com wrote: 1) export ExportSpecifierSet (, ExportSpecifierSet)* ; This rule seems too permissive. It allows strange combinations like: export x, { y: a.b.c, z }, { j, k }, * from bloop; I think it would be