[Harmony proxies] "if a trap is missing"

Tom Van Cutsem tomvc.be at gmail.com
Wed Dec 7 12:21:55 PST 2011

2011/12/6 David Bruant <bruant.d at gmail.com>

> "All traps are optional. If missing (more precisely, if
> handler[trapName] returns undefined), the proxy defaults to forwarding
> the intercepted operation to its target object." [1]
> Proxy({}, {get:undefined}).someProperty;
> In this case, the description says that the operation is forwarded. I
> would prefer a TypeError to be thrown in this case.

To do this, the proxy would need to test whether the trap actually exists,
by performing an "in" test on the handler.
This breaks the double lifting pattern [1], which depends on the only
interaction between the proxy and the handler being property access.

Aside from that main issue, I think it would be odd for Proxy({},{}).foo to
just work while Proxy({},{get:undefined}).foo would fail with a TypeError.


[1] See <http://wiki.ecmascript.org/doku.php?id=harmony:reflect_api>, last
code snippet under "Forwarding".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111207/a2e364b0/attachment.html>

More information about the es-discuss mailing list