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, there should not be no more constraints on private 
Symbol.<br><br>```js<br>var constructor=function(){<br>&nbsp; &nbsp; var 
privateField=Symbol('private', true);<br>&nbsp; &nbsp; var 
pubField=Symbol('public');<div>&nbsp; &nbsp; var leakedField=Symbol('leak', 
true);<br>&nbsp; &nbsp; return function something(arg){<br>&nbsp; &nbsp; &nbsp; 
&nbsp; this[privateField]=arg;<br>&nbsp; &nbsp; &nbsp; &nbsp; 
this[pubField]=arg;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; 
this[leakedField]=arg;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; 
this["leak"]=leakedField;<br>&nbsp; &nbsp; }<br>}<br>var arg="A";<br>var 
instance=new constructor(arg); // there is no way to access private 
fields<br>arg===instance[Object.getOwnPropertySymbols()[0]] // True, since 
Object.getOwnPrope
 rtySymbols expose the symbol</div><div>arg===instance[instance.leak]; // True, 
since instance.leak expose the symbol<br>```</div><div><br></div><div>Under 
careful use of the symbols, and without Object.getOwnPropertySymbols leaking 
every symbol, we can use symbols as private field.</div><div>V8 already has 
implemented private Symbol (just one more boolean field when defining the 
struct symbol) though it is not exposed to 
Script-side.<br><br>----------------------------------------<br>&gt; From: 
d...@domenic.me<br>&gt; To: waldron.r...@gmail.com; nbdd0...@hotmail.com; 
es-discuss@mozilla.org<br>&gt; Subject: RE: Proposal About Private 
Symbol<br>&gt; Date: Sat, 20 Dec 2014 20:11:04 +0000<br>&gt;<br>&gt; For more 
reasons on why a simple "private symbol" approach does not quite work, see 
https://github.com/zenparsing/es-abstract-refs/issues/11&amp;issuecomment-65723350<br>&gt;<br></div>
                                           
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to