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> var
privateField=Symbol('private', true);<br> var
pubField=Symbol('public');<div> var leakedField=Symbol('leak',
true);<br> return function something(arg){<br>
this[privateField]=arg;<br>
this[pubField]=arg;</div><div>
this[leakedField]=arg;</div><div>
this["leak"]=leakedField;<br> }<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>> From:
d...@domenic.me<br>> To: waldron.r...@gmail.com; nbdd0...@hotmail.com;
es-discuss@mozilla.org<br>> Subject: RE: Proposal About Private
Symbol<br>> Date: Sat, 20 Dec 2014 20:11:04 +0000<br>><br>> For more
reasons on why a simple "private symbol" approach does not quite work, see
https://github.com/zenparsing/es-abstract-refs/issues/11&issuecomment-65723350<br>><br></div>
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss