RE: A question about module/imports/exports

2012-08-27 Thread Luke Hoban
Hi, I'm writing a library for ES5 to add module system like ES6, I just want to confirm some behaviors of ES6 module system: module A { export var a = 'a' export function changeA(v) { a = v } } module B { import * from A console.log(a) // 'a' changeA('a1')

Re: A question about module/imports/exports

2012-08-27 Thread Shijun He
On Mon, Aug 27, 2012 at 2:11 PM, Luke Hoban lu...@microsoft.com wrote: And is there any difference if module A is write as: module A { var _a = 'a' export function changeA(v) { a = v } export {a: _a} } This should not work. There is no value in scope inside the module 'A'

Re: A question about module/imports/exports

2012-08-27 Thread Andreas Rossberg
On 27 August 2012 11:46, Shijun He hax@gmail.com wrote: On Mon, Aug 27, 2012 at 2:11 PM, Luke Hoban lu...@microsoft.com wrote: And is there any difference if module A is write as: module A { var _a = 'a' export function changeA(v) { a = v } export {a: _a} } This should

Re: A question about module/imports/exports

2012-08-27 Thread Shijun He
On Mon, Aug 27, 2012 at 5:55 PM, Andreas Rossberg rossb...@google.com wrote: No, Luke just meant that the assignment in changeA should read _a = v Oh, my typo! since that is the local name of the variable. After changing that, the module is indeed equivalent to the other version.

A question about Loader baseURL

2012-08-27 Thread Shijun He
It seems current loader spec is so simple and I'm full of confusion of baseURL props. // lib/a.js System.baseURL // lib/a.js ?? System.load('b.js', ...) // I suppose this should load lib/b.js, right? var myLoader = new Loader(System, { baseURL: 'mypath/c.js' , fetch:myFetch })

Re: A question about Loader baseURL

2012-08-27 Thread Sam Tobin-Hochstadt
On Mon, Aug 27, 2012 at 6:32 AM, Shijun He hax@gmail.com wrote: It seems current loader spec is so simple and I'm full of confusion of baseURL props. // lib/a.js System.baseURL // lib/a.js ?? No, the base url will be an absolute URL, like 'http://example.com/lib/a.js'.

Re: Experimental implementation of Object.observe JS Utilitylibrary now available

2012-08-27 Thread Andrea Giammarchi
Sorry guys, I just wonder if there's any outcome here ... rather than keep proposing something else :-) ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Some questions about Private Name Objects

2012-08-27 Thread Matthew Robb
So I have been trying to figure out from the wiki precisely how Private Name Objects work. When assigned/defined does it expose that property to all sibling properties/methods or just those present at the time of assign/define? If you add on to the object later to the new properties get access?

Re: Some questions about Private Name Objects

2012-08-27 Thread David Bruant
Le 27/08/2012 15:34, Matthew Robb a écrit : I'm trying to determine whether when compiling into ES3/5 you could get away with not attaching some .__privates__ property to the object and instead just put a closure around the definitions. For that question, the answer is you cannot. You cannot

Re: A question about Loader baseURL

2012-08-27 Thread Shijun He
On Mon, Aug 27, 2012 at 8:10 PM, Sam Tobin-Hochstadt sa...@ccs.neu.edu wrote: System.baseURL // lib/a.js ?? No, the base url will be an absolute URL, like 'http://example.com/lib/a.js'. So in /lib/b.js , System.baseURL will return a diff result http://example.com/lib/b.js; ? var myLoader =

Re: A question about Loader baseURL

2012-08-27 Thread Sam Tobin-Hochstadt
On Mon, Aug 27, 2012 at 10:07 AM, Shijun He hax@gmail.com wrote: On Mon, Aug 27, 2012 at 8:10 PM, Sam Tobin-Hochstadt sa...@ccs.neu.edu wrote: System.baseURL // lib/a.js ?? No, the base url will be an absolute URL, like 'http://example.com/lib/a.js'. So in /lib/b.js , System.baseURL

Re: A question about Loader baseURL

2012-08-27 Thread Kevin Smith
So how do myLoader know what is the URL of the caller?! I mean: I want: /a/*.js myLoader.load('test.js') // load /a/test.js /b/*.js myLoader.load('test.js') // load /b/test.js But myFetch get the identical args: ('test.js', myLoader.baseURL) This is a point that I've been meaning

Re: A question about Loader baseURL

2012-08-27 Thread Shijun He
On Mon, Aug 27, 2012 at 10:14 PM, Sam Tobin-Hochstadt sa...@ccs.neu.edu wrote: So in /lib/b.js , System.baseURL will return a diff result http://example.com/lib/b.js; ? This depends on how you're loading b.js. Could explain more about that? I suppose b.js is loaded by system loader. I

Re: A question about Loader baseURL

2012-08-27 Thread Kevin Smith
(This pretty much just repeats what hax said...) `load` is a method, which can be called anywhere. Having it depend on a dynamically-scoped bit of information such as the url of the file that the method is called in, would make using loaders much harder to understand. Perhaps, but I fear

Re: Some questions about Private Name Objects

2012-08-27 Thread Axel Rauschmayer
A name object is not much different from using a string: let myname1 = S4u-1_tlzUI; let myname2 = new Name(); someobj[myname1] = 123; someobj[myname2] = 123; // In a constructor or method: this[myname1] = abc; this[myname2] = abc; You can pass both around and create properties on any

Re: Some questions about Private Name Objects

2012-08-27 Thread Matthew Robb
SO it has to be constructed via new Name() or will it automatically create Name objects when it encounters an assignment of that form? If you do have to create it does that mean in order to access it at all you would need to be in scope of myname2? My question I think boils down to whether access

Re: Some questions about Private Name Objects

2012-08-27 Thread Axel Rauschmayer
On Aug 27, 2012, at 16:55 , Matthew Robb matthewwr...@gmail.com wrote: SO it has to be constructed via new Name() or will it automatically create Name objects when it encounters an assignment of that form? If you do have to create it does that mean in order to access it at all you would

Re: Some questions about Private Name Objects

2012-08-27 Thread Matthew Robb
AH okay thanks guys, questions answered! On Mon, Aug 27, 2012 at 11:03 AM, Axel Rauschmayer a...@rauschma.de wrote: On Aug 27, 2012, at 16:55 , Matthew Robb matthewwr...@gmail.com wrote: SO it has to be constructed via new Name() or will it automatically create Name objects when it

Re: Some questions about Private Name Objects

2012-08-27 Thread Matthew Robb
So why could this not desugar to?: var myClass = (function(){ var __test; function myClass() { __test = 0; } myClass.prototype.getTest = function(){ return __test; } return myClass; })(); On Mon, Aug 27, 2012 at 11:01 AM, David Bruant bruan...@gmail.com wrote: Le

Re: Some questions about Private Name Objects

2012-08-27 Thread David Bruant
Hi Matthew, Sorry, I mislead you. Let me retry: class myClass{ private test; constructor(){ this[test] = 0; } getTest(){return this[test]}; } desugars to: var myClass = (function(){ var test = new Name(); function

Re: Some questions about Private Name Objects

2012-08-27 Thread Matthew Robb
I know this has some serious ugly to it but in the spirit of knowing what COULD potentially create the expected behavior, would this not do the trick? var myClass = (function(){ function myClass(){ var __priv = Object.create(this); var __this = __priv.__this =

Re: About Array.of()

2012-08-27 Thread Rick Waldron
I don't think that screenshots of search suggestions for a language feature that hasn't even been published is valid argument in this discussion. I'd also argue that these results support the current Array.of definition, eg. I need to make an array of strings: Array.of( A, B, C, D ); ...Which

Re: About Array.of()

2012-08-27 Thread Brendan Eich
Just FTR, no one is proposing type guarded variants. Maybe they'll be wanted later -- so the alterna-constructor method(s) can be named then. For now, Array.new is polyfill-able on pre-ES5 implementations if you are willing to write Array['new'] all over. That is a drag, though. /be Matthew

Re: About Array.of()

2012-08-27 Thread Kevin Smith
Isn't there a name that we already use for alternative constructors: create? let object = Object.create(null); let array = Array.create(A, B, C); Kevin ___ es-discuss mailing list es-discuss@mozilla.org

Re: About Array.of()

2012-08-27 Thread Brendan Eich
Kevin Smith wrote: Isn't there a name that we already use for alternative constructors: create? let object = Object.create(null); let array = Array.create(A, B, C); If only create weren't used for Object.create, which takes a pdmap as second parameter. That is a complicated beast,

Re: Some questions about Private Name Objects

2012-08-27 Thread David Bruant
Le 27/08/2012 19:54, Matthew Robb a écrit : I know this has some serious ugly to it but in the spirit of knowing what COULD potentially create the expected behavior, would this not do the trick? var myClass = (function(){ function myClass(){ var __priv =

Re: Some questions about Private Name Objects

2012-08-27 Thread Kevin Smith
A last alternative is to associate private data via a WeakMap (it can be shimmed in ES5 with the same garbage collection properties and with good performances) that inherited functions all have access to. It works, but it's burdensome and doesn't read as well as object properties. On the

Re: Some questions about Private Name Objects

2012-08-27 Thread Matthew Robb
In the end I am not looking for reads well, I am looking for minimal semantic difference that can ideally work as a target for compiling to es3. I am PREFERRING to not have functions as ownProperties. I can't use hard binding because if the function is assigned to some place else it should no

Re: Some questions about Private Name Objects

2012-08-27 Thread David Bruant
Le 27/08/2012 21:22, Kevin Smith a écrit : A last alternative is to associate private data via a WeakMap (it can be shimmed in ES5 with the same garbage collection properties and with good performances) that inherited functions all have access to. It works, but it's burdensome

Re: About Array.of()

2012-08-27 Thread Rick Waldron
On Monday, August 27, 2012 at 3:12 PM, Brendan Eich wrote: Kevin Smith wrote: Isn't there a name that we already use for alternative constructors: create? let object = Object.create(null); let array = Array.create(A, B, C); If only create weren't used for Object.create,

Re: Some questions about Private Name Objects

2012-08-27 Thread Rick Waldron
On Monday, August 27, 2012 at 3:34 PM, Matthew Robb wrote: In the end I am not looking for reads well, I am looking for minimal semantic difference that can ideally work as a target for compiling to es3. I am PREFERRING to not have functions as ownProperties. I can't use hard binding

Re: About Array.of()

2012-08-27 Thread Shijun He
On Tue, Aug 28, 2012 at 1:55 AM, Rick Waldron waldron.r...@gmail.com wrote: I don't think that screenshots of search suggestions for a language feature that hasn't even been published is valid argument in this discussion. I'd also argue that these results support the current Array.of

Re: About Array.of()

2012-08-27 Thread Shijun He
On Tue, Aug 28, 2012 at 4:38 AM, Rick Waldron waldron.r...@gmail.com wrote: Regardless of its repositioning on the right as a property, I would intuitively expect new to behave the same way it would as its operator equivalent (for all constructors, not just Array). By no means do I wish to I

Re: About Array.of()

2012-08-27 Thread Brendan Eich
Shijun He wrote: On Tue, Aug 28, 2012 at 4:38 AM, Rick Waldronwaldron.r...@gmail.com wrote: Regardless of its repositioning on the right as a property, I would intuitively expect new to behave the same way it would as its operator equivalent (for all constructors, not just Array). By no means

Re: About Array.of()

2012-08-27 Thread Rick Waldron
On Mon, Aug 27, 2012 at 9:41 PM, Brendan Eich bren...@mozilla.org wrote: Shijun He wrote: On Tue, Aug 28, 2012 at 4:38 AM, Rick Waldronwaldron.r...@gmail.com** wrote: Regardless of its repositioning on the right as a property, I would intuitively expect new to behave the same way it would

Re: A question about Loader baseURL

2012-08-27 Thread Shijun He
Example: == my.js == var myLoader = new Loader(System, {fetch: myFetch} function myFetch(relURL, baseURL, ...) {...} myLoader.load('a/a.js', ...) == a/a.js == import x from 'a/a.js' // developer means to load a/a/a.js ... As I understand, imports in a/a.js (what in this case also import

Re: About Array.of()

2012-08-27 Thread 程劭非
Yes, as a developer (but not English native speaker), I really feel uncomfortable with the name “of”. Considering we already have Object.create String.fromCharCode To keep align with them, I belive “create” or “fromElements” might be better choices. 2012/8/27 Shijun He

Re: About Array.of()

2012-08-27 Thread 程劭非
Yes, as a developer (but not English native speaker), I really feel uncomfortable with the name “of”. Considering we already have Object.create String.fromCharCode To keep align with them, I belive “create” or “fromElements” might be better choices. 2012/8/27 Shijun He

Re: About Array.of()

2012-08-27 Thread Domenic Denicola
Array.fromElements is solid, especially considering how rarely this will be used, especially given that it competes in ES6 code with `...x = [...x]` On Aug 27, 2012, at 23:42, 程劭非 csf...@gmail.com wrote: Yes, as a developer (but not English native speaker), I really feel uncomfortable with