[[Invoke]] and implicit method calls

Tom Van Cutsem tomvc.be at gmail.com
Sat Sep 21 02:51:53 PDT 2013

2013/9/20 Allen Wirfs-Brock <allen at wirfs-brock.com>

> BTW, I would want to use  [[InvokeFunction]] for both directly
> obj.method() and in the internals of F.p.call/apply

As I mentioned to your reply at the time, I believe the latter would break
the expectations of existing code.

Code that uses F.p.call/apply to apply a function it acquired through
manual lookup typically expects it's going to execute the original
behavior, and nothing else:

var original_push = Array.prototype.push;
original_push.call(unknownObject, ...args); // programmer expects this to
either do the specced push() behavior or throw a TypeError (assuming
original definition of 'call')

JS fundamentally decouples property lookup from method call and thus has
the ability to express non-polymorphic function calls. We shouldn't
virtualize [[Call]]. If a proxy wants to intercept method calls, it can
return a wrapper function from its "get" trap and override "invoke". I'm
pretty sure virtualizing [[Call]] will be a bridge too far.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130921/91568a8d/attachment-0001.html>

More information about the es-discuss mailing list