Re: Some questions about Private Name Objects

2012-09-18 Thread Rick Waldron
I just spoke to Allen and need to make a correction the post above: computed properties were, in fact, later dropped. Rick On Fri, Sep 14, 2012 at 5:34 PM, Irakli Gozalishvili rfo...@gmail.comwrote: Hey Dean, I also really love clojure protocols and in fact tried to propose few extensions

Re: Some questions about Private Name Objects

2012-09-14 Thread Kevin Smith
The real point I'm trying to make is that Name objects give us something akin to clojure's protocols. Imagine an orm protocol -- this is just a set of names that must exist on an object (or its proto chain). An object can implement any number of protocols (or interfaces, or whatever) without

Re: Some questions about Private Name Objects

2012-09-14 Thread Rick Waldron
On Fri, Sep 14, 2012 at 12:58 PM, Kevin Smith khs4...@gmail.com wrote: The real point I'm trying to make is that Name objects give us something akin to clojure's protocols. Imagine an orm protocol -- this is just a set of names that must exist on an object (or its proto chain). An object can

Re: Some questions about Private Name Objects

2012-09-14 Thread Rick Waldron
On Thu, Sep 13, 2012 at 5:46 PM, Dean Landolt d...@deanlandolt.com wrote: On Thu, Sep 13, 2012 at 2:59 PM, Rick Waldron waldron.r...@gmail.comwrote: On Thu, Sep 13, 2012 at 1:46 PM, Dean Landolt d...@deanlandolt.comwrote: On Thu, Sep 13, 2012 at 12:09 PM, Erik Arvidsson

Re: Some questions about Private Name Objects

2012-09-14 Thread Irakli Gozalishvili
Hey Dean, I also really love clojure protocols and in fact tried to propose few extensions for private names to make them little more usable as such: https://mail.mozilla.org/pipermail/es-discuss/2012-June/023657.html https://gist.github.com/2967124 Unfortunately thread did not got any

Re: Some questions about Private Name Objects

2012-09-13 Thread Kevin Smith
It all start because of a fundamental missing piece in the language that is the ability to add a private property to an object. Not socially private as per the _field convention. I mean actually private, enforced by the runtime. I've been pondering this for a while now, and I think I've

Re: Some questions about Private Name Objects

2012-09-13 Thread Erik Arvidsson
On Thu, Sep 13, 2012 at 8:37 AM, Kevin Smith khs4...@gmail.com wrote: 1) Is method name-collision a practical problem, or just a theoretical problem? If it's just a theoretical problem, then we don't need unique names, and in teaching the language we can simply guide users away from trying to

Re: Some questions about Private Name Objects

2012-09-13 Thread Dean Landolt
On Thu, Sep 13, 2012 at 12:09 PM, Erik Arvidsson erik.arvids...@gmail.comwrote: On Thu, Sep 13, 2012 at 8:37 AM, Kevin Smith khs4...@gmail.com wrote: 1) Is method name-collision a practical problem, or just a theoretical problem? If it's just a theoretical problem, then we don't need unique

Re: Some questions about Private Name Objects

2012-09-13 Thread Kevin Smith
Another good example where this is a problem is on prototype chains, a good example of which you parenthetically noted (iterators). With unique names it becomes feasible to hang any properties and methods you want off of prototypes without worrying about collision. For instance, imagine an

Re: Some questions about Private Name Objects

2012-09-13 Thread Rick Waldron
On Thu, Sep 13, 2012 at 1:46 PM, Dean Landolt d...@deanlandolt.com wrote: On Thu, Sep 13, 2012 at 12:09 PM, Erik Arvidsson erik.arvids...@gmail.com wrote: On Thu, Sep 13, 2012 at 8:37 AM, Kevin Smith khs4...@gmail.com wrote: 1) Is method name-collision a practical problem, or just a

Re: Some questions about Private Name Objects

2012-09-13 Thread Dean Landolt
On Thu, Sep 13, 2012 at 2:59 PM, Rick Waldron waldron.r...@gmail.comwrote: On Thu, Sep 13, 2012 at 1:46 PM, Dean Landolt d...@deanlandolt.comwrote: On Thu, Sep 13, 2012 at 12:09 PM, Erik Arvidsson erik.arvids...@gmail.com wrote: On Thu, Sep 13, 2012 at 8:37 AM, Kevin Smith

Re: Some questions about Private Name Objects

2012-08-29 Thread Tom Van Cutsem
2012/8/27 David Bruant bruan...@gmail.com Le 27/08/2012 21:22, Kevin Smith a écrit : On the other hand, private names seem to add complexity to proxies A huge share of this complexity has been removed in recent discussions [1]. Conclusions seem to have reach consensus on es-discuss, but

Re: Some questions about Private Name Objects

2012-08-28 Thread Kevin Smith
Apologies in advance for the length... A huge share of this complexity has been removed in recent discussions [1]. Conclusions seem to have reach consensus on es-discuss, but nothing has been officially accepted by TC39 As I understand it, the solution arrived at was to provide a (possibly

Re: Some questions about Private Name Objects

2012-08-28 Thread David Bruant
Le 28/08/2012 15:38, Kevin Smith a écrit : Apologies in advance for the length... Don't. We're here to discuss as the mailing-list name suggests. And if what you need to say is long, so be it. A huge share of this complexity has been removed in recent discussions [1]. Conclusions

Re: Some questions about Private Name Objects

2012-08-28 Thread Claus Reinke
Unique (non-private) names offer mixins without collisions. But any general mixin utility will fail if the source object relies on privately named methods for its functionality: ... Neither the destination object nor the library function mixin has access to the private name, and therefore the

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: 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: 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: 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