Re: simpler, sweeter syntax for modules

2012-03-22 Thread David Herman
On Mar 21, 2012, at 9:28 PM, John J Barton wrote: equals makes sense when it is assigment: module Bar = load(bar.js); It's not an assignment, though. Which is why Brendan didn't like it in the first place, since he felt programmers would get confused that it was a dynamic assignment

Re: simpler, sweeter syntax for modules

2012-03-22 Thread David Herman
On Mar 21, 2012, at 9:41 PM, Brendan Eich wrote: Perhaps Python has the right syntax, then? from foo.js import foo; import foo.js as Foo; I suppose we could. I always thought this was an awkward choice on Python's part. The first line always reminds me of the Yinglish constructions my

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Brendan Eich
David Herman wrote: On Mar 21, 2012, at 9:28 PM, John J Barton wrote: equals makes sense when it is assigment: module Bar = load(bar.js); It's not an assignment, though. Which is why Brendan didn't like it in the first place, since he felt programmers would get confused that it was a

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Gavin Barraclough
On Mar 21, 2012, at 3:28 PM, David Herman wrote: * importing with renaming: import { draw: drawGun }from cowboy.js, { draw: drawWidget } from widgets.js; Hey Dave, This all looks really nice! - the only thing that threw me was the export rename – I intuitively expect the

Re: const initializers: once more unto the breach

2012-03-22 Thread Andreas Rossberg
On 21 March 2012 20:05, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Mar 21, 2012, at 10:11 AM, Brendan Eich wrote: Andreas Rossberg wrote: Right, but my comment was only about checking of assignments to const variables. Those are always an error, regardless of TDZ behaviour.

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Peter van der Zee
On Wed, Mar 21, 2012 at 11:28 PM, David Herman dher...@mozilla.com wrote: * importing with renaming:    import { draw: drawGun }    from cowboy.js,           { draw: drawWidget } from widgets.js; The brackets don't seem necessary (at least not from a parsing perspective). Maybe drop them?

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Andreas Rossberg
On 22 March 2012 10:23, Peter van der Zee e...@qfox.nl wrote: On Wed, Mar 21, 2012 at 11:28 PM, David Herman dher...@mozilla.com wrote: * importing with renaming: import { draw: drawGun }from cowboy.js, { draw: drawWidget } from widgets.js; The brackets don't seem

Re: UUIDs?

2012-03-22 Thread 程劭非
UUID is not only a random Number or String. It has to contain time and position to make itself unique in the world. It looks Math.random is related to time. We have no way to involve position information to JS currently. 2012/3/16 Nuno Job nunojobpi...@gmail.com: Wrong list, sorry about that :)

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Herby Vojčík
David Herman wrote: On Mar 21, 2012, at 9:28 PM, John J Barton wrote: equals makes sense when it is assigment: module Bar = load(bar.js); It's not an assignment, though. Which is why Brendan didn't like it in the first place, since he felt programmers would get confused that it was a

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Andreas Rossberg
On 22 March 2012 02:35, David Herman dher...@mozilla.com wrote: Follow-up: I've factored out these two alternative approaches, both of which I think are defensible. Grammars: http://wiki.ecmascript.org/doku.php?id=harmony:modules#syntax Nice! One question: is there a reason why you not

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Andreas Rossberg
On 22 March 2012 07:12, David Herman dher...@mozilla.com wrote: On Mar 21, 2012, at 9:01 PM, Axel Rauschmayer wrote: I like variant B, because it follows the rules: - module = define a module - import = extract something out of a module As Dave already mentioned, that is my stance, too.

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Andreas Rossberg
On 22 March 2012 07:33, Brendan Eich bren...@mozilla.org wrote: David Herman wrote: On Mar 21, 2012, at 9:28 PM, John J Barton wrote: equals makes sense when it is assigment: module Bar = load(bar.js); It's not an assignment, though. Which is why Brendan didn't like it in the first

Re: simpler, sweeter syntax for modules

2012-03-22 Thread brad dunbar
This is great stuff. I've got a quick question about the `as` keyword. import 'foo.js' as Foo; Is there any reason we can't simply do var Foo = import 'foo.js'; When looking for the source of a variable, I often search for /Foo =/ to discern it's origin and it only seems natural that giving

RE: simpler, sweeter syntax for modules

2012-03-22 Thread Domenic Denicola
Callable modules are a hugely important use case. jQuery and Underscore spring to mind. I’ve made one myself [1]. Also important: what about construct-able modules? Or to put it another way, what about exporting a module that is a class? Examples from Node [2] [3] and Node-land [4] [5] are

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Kevin Smith
Correct me if I have any of this wrong, but modules don't need to be callable for the jQuery use case: // jquery.js export function $(...) { ... } // program.js import $ from path/to/jquery.js; $(#elem).whatever We don't need node style modules-as-classes either: //

Re: simpler, sweeter syntax for modules

2012-03-22 Thread David Herman
On Mar 22, 2012, at 4:55 AM, Andreas Rossberg wrote: One point that I haven't seen mentioned yet (and it is unrelated to syntax): export call makes me cringe -- making modules callable is not just weird, it seems completely future-hostile to the possibility of having parameterized modules.

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Russell Leggett
That said, it requires no more code to say: // jquery.js export function $(selector) { ... } ... // client import $ from jquery.js; let elements = [foo, bar, baz].map($); $(quux).style(...); So maybe people have over-sold the importance of callable modules. In

Re: Harmony helpwanted: Proxy, Map discrepancy between V8 and SpiderMonkey

2012-03-22 Thread Andreas Rossberg
On 21 March 2012 21:00, Alex Vincent ajvinc...@gmail.com wrote: https://www.alexvincent.us/temp/ProxyCtor/V8-SpiderMonkey-test.html I reduced the testcase quite severely. It's a combination between Proxy and WeakMap. I store the proxy as a key for the WeakMap, and then expect to get back

Re: simpler, sweeter syntax for modules

2012-03-22 Thread David Herman
On Mar 22, 2012, at 4:46 AM, Andreas Rossberg wrote: Nice! One question: is there a reason why you not just define Program ::= ModuleBody ? No exports from a Program. Dave ___ es-discuss mailing list es-discuss@mozilla.org

Re: simpler, sweeter syntax for modules

2012-03-22 Thread David Herman
On Mar 22, 2012, at 4:48 AM, Andreas Rossberg wrote: On 22 March 2012 07:33, Brendan Eich bren...@mozilla.org wrote: But why make misleading syntax? More of a question for John: why write |load(bar.js)| there, looking for all the world like a function call evaluated in order at runtime,

Re: simpler, sweeter syntax for modules

2012-03-22 Thread John J Barton
On Wed, Mar 21, 2012 at 11:33 PM, Brendan Eich bren...@mozilla.org wrote: David Herman wrote: On Mar 21, 2012, at 9:28 PM, John J Barton wrote: equals makes sense when it is assigment:   module Bar = load(bar.js); It's not an assignment, though. Which is why Brendan didn't like it in the

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Andreas Rossberg
On 22 March 2012 16:30, David Herman dher...@mozilla.com wrote: On Mar 22, 2012, at 4:46 AM, Andreas Rossberg wrote: Nice! One question: is there a reason why you not just define Program ::= ModuleBody ? No exports from a Program. Except that the syntax currently includes that.

Re: const initializers: once more unto the breach

2012-03-22 Thread Brendan Eich
Allen Wirfs-Brock wrote: On Mar 21, 2012, at 10:11 AM, Brendan Eich wrote: Andreas Rossberg wrote: Right, but my comment was only about checking of assignments to const variables. Those are always an error, regardless of TDZ behaviour. Agreed, absolutely. In all-strict code we know

RE: simpler, sweeter syntax for modules

2012-03-22 Thread Luke Hoban
The bracket syntax is pretty confusing with object literal notation imo. It shouldn't be too confusing, and the similarity is in fact intentional. You should read import as destructuring (and export as the inverse structuring, if you want). I agree that this isn't really a question

Re: Finding a safety syntax for classes

2012-03-22 Thread Allen Wirfs-Brock
I've created a strawman proposal for Russell's class safety syntax: http://wiki.ecmascript.org/doku.php?id=strawman:maximally_minimal_classes Allen ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: UUIDs?

2012-03-22 Thread Mark S. Miller
What does time or position have to do with uniqueness? Why not velocity, spin and charm? Seriously, given a good source of entropy, a large enough random number is globally unique. Math.random() is not a good source of entropy, but crypto.getRandomValues is. See

Re: const initializers: once more unto the breach

2012-03-22 Thread Allen Wirfs-Brock
On Mar 22, 2012, at 9:10 AM, Brendan Eich wrote: Allen Wirfs-Brock wrote: On Mar 21, 2012, at 10:11 AM, Brendan Eich wrote: Andreas Rossberg wrote: Right, but my comment was only about checking of assignments to const variables. Those are always an error, regardless of TDZ

Re: Finding a safety syntax for classes

2012-03-22 Thread Kevin Smith
Looks great. A couple of questions (I may have missed something): 1.) What is a generator method? *PropertyName ( FormalParameterList? ) { FunctionBody } // generator method 2.) What happens if the AssignmentExpression to the right of extends evaluates to something that doesn't have a

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Brendan Eich
Andreas Rossberg wrote: I still wonder why you think it is so confusing to use the equality sign for module bindings. It is overloaded to mean define as and assign in almost all language that use it for the latter, and for different semantic categories, too. I never witnessed anybody being

Re: UUIDs?

2012-03-22 Thread 程劭非
Random number in big enough range could replace uuid in most cases. But it's still not truely unique. In specified time and specified position(specified device), you can make sure there is only one uuid generated. BTW, we are using crypto.getRandomValues in our project, it works well until now.

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Brendan Eich
David Herman wrote: The 'at' might be appropriate but it just looks like an unfinished thought: the module foo at 'foo.js' ...what? Both the import-as and module-= forms state what the declaration is doing. The former declares it is importing the module; the latter declares it is

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Brendan Eich
John J Barton wrote: I guess you mean: a special form evaluated before the outer function runs? Surely this form is not off-line. No, before anything in the containing Program (up to the script container) runs. Modules are prefetched, not loaded by a nested event loop that violates

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Allen Wirfs-Brock
On Mar 22, 2012, at 9:12 AM, Luke Hoban wrote: The bracket syntax is pretty confusing with object literal notation imo. It shouldn't be too confusing, and the similarity is in fact intentional. You should read import as destructuring (and export as the inverse structuring, if you want).

Re: Finding a safety syntax for classes

2012-03-22 Thread Allen Wirfs-Brock
On Mar 22, 2012, at 10:05 AM, Kevin Smith wrote: Looks great. A couple of questions (I may have missed something): 1.) What is a generator method? *PropertyName ( FormalParameterList? ) { FunctionBody } // generator method http://wiki.ecmascript.org/doku.php?id=harmony:generators

Re: Finding a safety syntax for classes

2012-03-22 Thread Kevin Smith
Ah - knew I'd missed something completely obvious - thanks! kevin ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Brendan Eich
Luke Hoban wrote: At least half the times I've shown object destructuring or module import renaming syntax I've gotten don't you have that backwards? remarks. I can't say I have a better recommendation for the general object destructuring syntax, but I expect this to be a point of

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Brendan Eich
Allen Wirfs-Brock wrote: I also find myself getting it backwards, but it helps me to remember that for destructing assignment the target needs to be an arbitrary LHS which won't really fit well to the right of the : You mean left, not right. ;-) /be

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Allen Wirfs-Brock
On Mar 22, 2012, at 10:56 AM, Brendan Eich wrote: Allen Wirfs-Brock wrote: I also find myself getting it backwards, but it helps me to remember that for destructing assignment the target needs to be an arbitrary LHS which won't really fit well to the right of the : You mean left, not

Re: UUIDs?

2012-03-22 Thread Mark S. Miller
On Thu, Mar 22, 2012 at 10:20 AM, 程劭非 csf...@gmail.com wrote: Random number in big enough range could replace uuid in most cases. But it's still not truely unique. In specified time and specified position(specified device), you can make sure there is only one uuid generated. How do you

Re: UUIDs?

2012-03-22 Thread Adam Shannon
I agree, UUID's are becoming increasingly more useful for applications as apps need quick and unique identifiers to send back and form relationships between data. On Thursday, March 22, 2012, 程劭非 csf...@gmail.com wrote: Random number in big enough range could replace uuid in most cases. But

Re: simpler, sweeter syntax for modules

2012-03-22 Thread John J Barton
On Thu, Mar 22, 2012 at 10:32 AM, Brendan Eich bren...@mozilla.org wrote: John J Barton wrote: I guess you mean:  a special form evaluated before the outer function runs? Surely this form is not off-line. No, before anything in the containing Program (up to the script container) runs.

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Brendan Eich
John J Barton wrote: Second, we need a solution for asynchronous loading with run-time selection. We use it now and as we move to much better network layers we will use it a lot more. Of course. This is what the http://wiki.ecmascript.org/doku.php?id=harmony:module_loaders API is all about.

Re: simpler, sweeter syntax for modules

2012-03-22 Thread John J Barton
On Thu, Mar 22, 2012 at 1:54 PM, Brendan Eich bren...@mozilla.org wrote: John J Barton wrote: Second, we need a solution for asynchronous loading with run-time selection. We use it now and as we move to much better network layers we will use it a lot more. Of course. This is what the

clojure like protocols

2012-03-22 Thread Irakli Gozalishvili
I have published a [blog post] about JS [protocol library] that implements clojure like polymorphism, which is interesting as it solves typical [problems with classes]. From my experiment I got a feeling that it may be a much better feet for JS language than classes, so I thought it's worth

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Sam Tobin-Hochstadt
On Thu, Mar 22, 2012 at 5:11 PM, John J Barton johnjbar...@johnjbarton.com wrote: The module solution posted seems to have a top-notch solution for the static case but the dynamic case is buried in the loader. I don't really understand what you mean by buried in the loader. Here's the dynamic

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Claus Reinke
Btw, another question that has bugged me lately: with 1JS, what happens when I do a sloppy-mode direct eval on a program string containing a module declaration? In global scope? In local scope? It's a good question, and one I've thought about some. This could use some whiteboard time -- let's

Re: simpler, sweeter syntax for modules

2012-03-22 Thread John J Barton
On Thu, Mar 22, 2012 at 3:06 PM, Sam Tobin-Hochstadt sa...@ccs.neu.edu wrote: On Thu, Mar 22, 2012 at 5:11 PM, John J Barton johnjbar...@johnjbarton.com wrote: The module solution posted seems to have a top-notch solution for the static case but the dynamic case is buried in the loader. I

Re: UUIDs?

2012-03-22 Thread Jussi Kalliokoski
2012/3/22 Mark S. Miller erig...@google.com On Thu, Mar 22, 2012 at 10:20 AM, 程劭非 csf...@gmail.com wrote: Random number in big enough range could replace uuid in most cases. But it's still not truely unique. In specified time and specified position(specified device), you can make sure

Re: clojure like protocols

2012-03-22 Thread Brandon Benvie
Maye I'm crazy but this seems like IDL in a more JavaScript friendly form. Not just WebIDL JavaScript semantics and types friendly, but targeted at implementation using JavaScript which is less friendly and requires Proxy wrappers for many/most things like dom.js does. Which is a good thing and I

Re: simpler, sweeter syntax for modules

2012-03-22 Thread John J Barton
On Thu, Mar 22, 2012 at 4:54 PM, Brendan Eich bren...@mozilla.org wrote: John J Barton wrote: If I go back to my previous question, can we understand what should happen here? if (version === 1)  import y from 'lib1.js'; else  import y from 'lib2.js'; Again, no. No, we can't understand

Re: clojure like protocols

2012-03-22 Thread Irakli Gozalishvili
Regards -- Irakli Gozalishvili Web: http://www.jeditoolkit.com/ On Thursday, 2012-03-22 at 17:09 , Brandon Benvie wrote: Maye I'm crazy but this seems like IDL in a more JavaScript friendly form. Not just WebIDL JavaScript semantics and types friendly, but targeted at implementation

Re: simpler, sweeter syntax for modules

2012-03-22 Thread Brendan Eich
John J Barton wrote: On Thu, Mar 22, 2012 at 4:54 PM, Brendan Eichbren...@mozilla.org wrote: John J Barton wrote: If I go back to my previous question, can we understand what should happen here? if (version === 1) import y from 'lib1.js'; else import y from 'lib2.js'; Again, no. No,

Re: Finding a safety syntax for classes

2012-03-22 Thread Kevin Smith
Since the method name is specified as PropertyName, it will allow bracketed expressions for names, correct? class A { [maybePrivateMethod]() { ... } } kevin ___ es-discuss mailing list es-discuss@mozilla.org

Re: Finding a safety syntax for classes

2012-03-22 Thread Brendan Eich
David Herman wrote: I do think that class declarations should be hoisted, both in the sense of being in scope for the whole containing block (as with let and function) and in the sense of being initialized before the block begins executing (as with function). Allen has argued against

Re: Finding a safety syntax for classes

2012-03-22 Thread Brendan Eich
Rick Waldron wrote: I've taken my previous tri-lambda-syntax support example (https://gist.github.com/2013909) and I've updated the code to use your proposed class syntax... It looks nice: https://gist.github.com/2139330 This is sweet! Even without the thin-arrow function expression. /be

Re: Finding a safety syntax for classes

2012-03-22 Thread Brendan Eich
Russell Leggett wrote: Well, I favour constructor because it blends well with the underlying mechanics... there _is_ a property named constructor in a prototype, pointing exactly to the constructor method of that prototype. So if I looks at the class {...} block as a blueprint

Re: clojure like protocols

2012-03-22 Thread Brandon Benvie
Yeah that's what I was trying to say. This is suited towards use in JavaScript whereas IDL isn't. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Finding a safety syntax for classes

2012-03-22 Thread Brendan Eich
Brendan Eich wrote: Allen has argued against hoisting, based on the extends clause being an evaluated expression. Also (if included) based on static property initializers being evaluated, intuitively in declaration/statement order, but if you hoist the class when do you evaluate the statics'

Re: Finding a safety syntax for classes

2012-03-22 Thread Russell Leggett
On Fri, Mar 23, 2012 at 12:30 AM, Brendan Eich bren...@mozilla.org wrote: Brendan Eich wrote: Allen has argued against hoisting, based on the extends clause being an evaluated expression. Also (if included) based on static property initializers being evaluated, intuitively in

Re: Full Unicode based on UTF-16 proposal

2012-03-22 Thread Norbert Lindenberg
I've updated the proposal based on the feedback received so far. Changes are listed in the Updates section. http://norbertlindenberg.com/2012/03/ecmascript-supplementary-characters/ Norbert On Mar 16, 2012, at 0:18 , Norbert Lindenberg wrote: Based on my prioritization of goals for support

Re: Finding a safety syntax for classes

2012-03-22 Thread Brendan Eich
Russell Leggett wrote: This is what Allen said about hoisting for this spec (Its been a long thread, not sure if you missed this.): Thanks, I did catch up that far on the thread, but Allen reiterated the point he'd made months ago: you can't hoist *and initialize* the class declaration as