Re: Proposal About Private Symbol

2014-12-21 Thread Tab Atkins Jr.
On Sat, Dec 20, 2014 at 10:41 PM, Gary Guo nbdd0...@hotmail.com wrote: Oops, mistakes found. I just ignored the fact that in this particular way the Symbol can be retrieved. It seems impossible to have an idea of private symbol in this way. In the case, I think the language can provide a way

RE: Proposal About Private Symbol

2014-12-21 Thread Gary Guo
From: jackalm...@gmail.com Date: Sun, 21 Dec 2014 00:45:40 -0800 There are ways around this, too - create your own Symbol, keep it closure-private to the class, so it doesn't escape the class's methods. Have the constructor take an extra argument that must be equal to this symbol; if it's

RE: Proposal About Private Symbol

2014-12-21 Thread Michał Wadas
But this is not the core of the problem. The problem is the Proxy introduced in ES6 enables an object to capture and override almost any operation on an object. Without operation on object, it becomes very costly (by using an Array of created objects and compare each of them) to identify whether

RE: Proposal About Private Symbol

2014-12-21 Thread Gary Guo
Oops, I forget the WeakSet. So seems my private symbol proposal can work now. Under very deliberately design, private symbol can be used as private field. ```jsvar constructor=function(){'use strict';var allObjects=new WeakSet();var privateSymbol=Symbol('private', true);var

RE: Proposal About Private Symbol

2014-12-21 Thread Domenic Denicola
Subject: RE: Proposal About Private Symbol Oops, I forget the WeakSet. So seems my private symbol proposal can work now. Under very deliberately design, private symbol can be used as private field. ```js var constructor=function(){ 'use strict'; var allObjects=new WeakSet(); var

RE: Proposal About Private Symbol

2014-12-21 Thread Domenic Denicola
That breaks membranes. From: Gary Guomailto:nbdd0...@hotmail.com Sent: ‎2014-‎12-‎21 20:00 To: Domenic Denicolamailto:d...@domenic.me Cc: es-discuss@mozilla.orgmailto:es-discuss@mozilla.org Subject: RE: Proposal About Private Symbol I didn't quite get the point

Re: Proposal About Private Symbol

2014-12-21 Thread Kevin Smith
```js var constructor=function(){ 'use strict'; var allObjects=new WeakSet(); var privateSymbol=Symbol('private', true); var ret=function(){ if(this===undefined)throw Error('Invalid Construction'); this[privateSymbol]=1; allObjects.add(this);

Proposal About Private Symbol

2014-12-20 Thread Gary Guo
I have just sent this proposal through http://www.ecma-international.org/memento/register_TC39_Royalty_Free_Task_Group.php but I don't know what more I need to do. I am a high school student from China who is interested in next-generation ecmascript and has been working on an ecmascript

RE: Proposal About Private Symbol

2014-12-20 Thread Gary Guo
I don't think it's a problem though. As long as the private Symbol doesn't leak, there is no way to access private properties. Private Symbol as I supposed only eliminate itself from getOwnPropertySymbols, and that's it,nbsp;there should not be no morenbsp;constraintsnbsp;on private

RE: Proposal About Private Symbol

2014-12-20 Thread Gary Guo
it is not exposed to Script-side. From: d...@domenic.me To: waldron.r...@gmail.com; nbdd0...@hotmail.com; es-discuss@mozilla.org Subject: RE: Proposal About Private Symbol Date: Sat, 20 Dec 2014 20:11:04 + For more reasons on why a simple private

RE: Proposal About Private Symbol

2014-12-20 Thread Domenic Denicola
Subject: RE: Proposal About Private Symbol Oops, seems Outlook.com ruins my email. One more time I don't think it's a problem though. As long as the private Symbol doesn't leak, there is no way to access private properties. Private Symbol as I supposed only eliminate itself from

RE: Proposal About Private Symbol

2014-12-20 Thread Gary Guo
problems there. From: d...@domenic.me To: nbdd0...@hotmail.com; es-discuss@mozilla.org Subject: RE: Proposal About Private Symbol Date: Sun, 21 Dec 2014 02:58:15 + Did you read the linked post? The problem is completely different from the one you describe. It is about interoperability

Re: Proposal About Private Symbol

2014-12-20 Thread Kevin Smith
Under careful use of the symbols, and without Object.getOwnPropertySymbols leaking every symbol, we can use symbols as private field. There are other ways that symbols can leak besides `getOwnPropertySymbols`. Take a look at proxies, which allow you to intercept [[Get]] and [[Set]]. In

Re: Proposal About Private Symbol

2014-12-20 Thread Kevin Smith
2. They would not invoke any traps on proxies. 3. They would not tunnel through proxies to proxy targets. 4. Getting a private-symbol-keyed property would not traverse the prototype chain of the object (perhaps arguable). Unnecessary, as long as symbol doesn't leak to external environment, I

RE: Proposal About Private Symbol

2014-12-20 Thread Gary Guo
This');         this[sym]=1;     }     return ret.bind(undefined); }(); ``` Date: Sat, 20 Dec 2014 22:48:37 -0500 Subject: Re: Proposal About Private Symbol From: zenpars...@gmail.com To: nbdd0...@hotmail.com CC: es-discuss@mozilla.org 2. They would

RE: Proposal About Private Symbol

2014-12-20 Thread Gary Guo
This');         this[sym]=1;     }     return ret.bind(undefined); }(); ``` From: nbdd0...@hotmail.com To: es-discuss@mozilla.org Subject: RE: Proposal About Private Symbol Date: Sun, 21 Dec 2014 12:08:09 +0800 Technically speaking there is no way to prevent