Are Private name and Weak Map the same feature? and the Assoc API

Tom Van Cutsem at
Mon Dec 19 07:50:41 PST 2011

2011/12/19 Tom Van Cutsem < at>

> Calling the trap and catching a special exception is something that we
> have avoided in the proxy design thus far. One possibility is to have the
> "getPrivate" trap return a boolean. If the trap returns false, the proxy
> will forward the private name access. This would allow the getPrivate trap
> to check whether the "public" argument corresponds to one of its own
> private names. If not, it just returns false (no throwing exceptions or
> calling special Proxy.getDefault methods needed).

Sorry, this doesn't work. The getPrivate trap already uses its return value
to indicate the value of the private name.
So yes, if the getPrivate trap wants to trigger the "default behavior" it
either has to throw a special exception or return a special unique value to
indicate this. It's an interesting difference with all other traps, which
can just perform the default forwarding behavior by calling one of the
Reflect.* methods. Obviously, we can't provide a Reflect.getPrivate(target,
public) since that breaks the entire point of the private/public
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list