July 26, 2012 TC39 Meeting Notes
Tom Van Cutsem
tomvc.be at gmail.com
Tue Jul 31 10:09:08 PDT 2012
2012/7/31 Brandon Benvie <brandon at brandonbenvie.com>
> You can still do useful things even without access to the public name
> though, as long as you can still forward to the target and get the result
> back. This allows you to instrument the action and to associate it with
> something unique even if you don't have a way to access the name and it's
> valuable arbitrarily outside of the trap. However, if there's no way to
> forward it correctly then the trap can't really exist at all anyway.
No, if a handler intercepts a private name access for a private name it
doesn't know, it has no way of forwarding the access in such a way that it
can still intercept the result. That would allow the handler to read or
change the value of a private name it doesn't know.
The only way a handler can forward a private name access is by returning
undefined from its getName trap. The forwarding at that point is done by
the proxy, with no further interaction with the handler. The handler
doesn't get to change the value returned from target[name]. This is crucial.
AFAICT, the only two useful things a handler can do when it intercepts a
private name it knows nothing about is:
1) ask the proxy to forward
If the handler does know of the private name, or the name is unique, then
the handler can do the forwarding itself and intercept/change/decorate the
result as usual.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss