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 getOwnPropertySymbols, and that's it, there
should not be no more constraints on private Symbol.
```js
var constructor=function(){
var privateField=Symbol('private', true);
var pubField=Symbol('public');
var leakedField=Symbol('leak', true);
return function something(arg){
this[privateField]=arg;
this[pubField]=arg;
this[leakedField]=arg;
this["leak"]=leakedField;
}
}
var arg="A";
var instance=new constructor(arg); // there is no way to access private fields
arg===instance[Object.getOwnPropertySymbols()[0]] // True, since
Object.getOwnPropertySymbols expose the symbol
arg===instance[instance.leak]; // True, since instance.leak expose the symbol
```
Under careful use of the symbols, and without Object.getOwnPropertySymbols
leaking every symbol, we can use symbols as private field.
V8 already has implemented private Symbol (just one more boolean field when
defining the struct symbol) though it is not exposed to Script-side.
----------------------------------------
> From: [email protected]
> To: [email protected]; [email protected]; [email protected]
> Subject: RE: Proposal About Private Symbol
> Date: Sat, 20 Dec 2014 20:11:04 +0000
>
> 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
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss