2011/8/11 Brendan Eich <[email protected]>

>
> This seems to miss Sean's point that receiver is never other than the proxy
> for get and set. That follows from how native object [[Get]] works in ES5.
>

You're right. Using the "get" trap as an example was silly, since it already
has access to receiver, which is the proxy. Your comment made me revisit all
derived traps again, and I think I found a compelling and easy-to-understand
rule for determining whether or not a trap needs access to proxy/receiver:
if the trap deals with inherited properties, it needs access to |proxy|.

Using that rule, the following traps require access to |proxy|:
get, set, getPropertyDescriptor, getPropertyNames, has, enumerate
(incidentally, all of these traps are or can be made derived)

All other traps deal only with "own" properties, and do not need |proxy|:
getOwnPropertyDescriptor, getOwnPropertyNames, defineProperty, delete, fix,
hasOwn, keys

getPropertyDescriptor and getPropertyNames require access to |proxy| to walk
the prototype-chain. The default behavior of get, set, has and enumerate is
specified in terms of either or both of these traps, so they also need
access to |proxy|. Note that get and set depend on |proxy| for two reasons:
1) to correctly set |this| for accessors, 2) to be able to lookup a property
on the prototype chain (via |Object.getPropertyDescriptor(proxy, name)| )

Cheers,
Tom
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to