2011/12/19 Tom Van Cutsem <[email protected]>
> In any case, by separating private name access out into separate traps, if
> a proxy writer only implements get/set but not getPrivate/setPrivate, then
> private name access would just be forwarded to the proxy target by default,
> and there would be no need for the proxy to maintain a public->private
> mapping for private names it does not know or care about.
>
To clarify: the proxy logic I was thinking of is along the following lines:
// in the VM, when intercepting proxy[privateName]:
var trap = handler.getPrivate;
if (typeof trap === "function") {
return trap.call(handler, target, privateName.public); // note: no
ToString on privateName.public
} else {
return target[privateName]; // note: not target[privateName.public] !!
}
It's that else-branch that makes this work out: if the proxy doesn't
implement the getPrivate trap, private names will continue to work just
fine. With the .public conversion, any proxy that does not special-case
private names in its get trap will be broken: it'll forward the wrong
property name.
Cheers,
Tom
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss