Adding [[Invoke]] to address issues with methods called on Proxies

Brandon Benvie brandon at brandonbenvie.com
Tue Jan 29 02:54:45 PST 2013


The issues with private state (either WeakMaps or private symbols) and
Proxies seems to largely boil down to the lack of the ability to bind
|this| in forwarding method invocations to the target. This is the same
limitation that prevents Proxies from being able to fully replace
__noSuchMethod__. In either case, the internal state of the object is
|this| sensitive and methods called on the Proxy can either malfunction or,
in the case of WeakMap stored state, are completely unable to work.

A solution to this would be to add an [[Invoke]] internal method and a
corresponding "invoke" Proxy trap. awb has referred to this as
[[CallProperty]](property), but I think it might actually be better to use
[[Invoke]](method) so that super calls can be trapped. The difference
between the two is visible to a Proxy: [[Invoke]] would be "get" (usually)
and then "invoke", [[CallProperty]] would be "callProperty" and then
potentially a "get" (when forwarded). [[Invoke]] would also allow .call and
.apply to be trapped as "invoke" instead of not trapped at all.

Outside of Proxies, this change wouldn't be observable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130129/144a5cc5/attachment-0001.html>


More information about the es-discuss mailing list