[[Invoke]] and implicit method calls

Tom Van Cutsem tomvc.be at gmail.com
Wed Sep 25 01:45:55 PDT 2013

2013/9/24 Brandon Benvie <bbenvie at mozilla.com>

> It seems unfortunate that we have to rely on a membrane for something as
> simply as `new Proxy(new Date, {}).getDate()` to work. [[Invoke]] as
> currently specced gets us somewhere at least.

You don't necessarily need a full membrane if you want that specific call
to work. If a proxy's "get" trap just returns a bound-function (with |this|
bound to target), this will work fine. I would postulate that this solution
easily covers the 90% case. Yes, methods can be objects with properties in
JS, and bound functions won't proxy those, but that isn't the common case.

JS programmers have been using function-wrappers since forever (including
bound functions since ES5). Bound functions aren't perfect forwarding
wrappers either. People seem to cope.

Perfect is the enemy of the good and all that ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130925/fb6b8328/attachment.html>

More information about the es-discuss mailing list