Proxies: wrong "receiver" used in default "set" trap

Tom Van Cutsem at
Thu Dec 20 02:21:09 PST 2012

2012/12/19 Allen Wirfs-Brock <allen at>

> If we make the Option A change that seems right for  [[GetP]]/[[SetP]]
> then we will have an inconsistency between the this value used for a method
> invoked as and a accessor invoked as

To clarify, if we apply the fix to [[SetP]] described in my previous
message, the following remains the default forwarding behavior of proxies:

If is a method: will call with |this| bound to the proxy (i.e.
Lieberman-style delegation)

If is an accessor: will call the getter with |this| bound to the proxy
(delegation) = 42 will call the setter with |this| bound to the
proxy (delegation)

If target.baz is a writable data property
proxy.baz = 42 will eventually call Object.defineProperty(proxy, 'baz',
(and *not* Object.defineProperty(proxy, 'baz',
{value:42,enumerable:true,writable:true,configurable:true}) as it did
This behavior is consistent with the method and accessor case: in all
cases, the target delegates back to the proxy.

This bears repeating: the above are only defaults, and proxy authors are
free to change the policy by actually implementing traps and taking control.

One thing that I learned from all this is that it's simpler to think of the
proxy as *delegating* (as opposed to forwarding) to its target by default.
And under the semantics of invoke = get + apply, that is actually the
simplest option.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list