[[Invoke]] and implicit method calls

Tom Van Cutsem tomvc.be at gmail.com
Wed Sep 11 03:29:44 PDT 2013


2013/9/10 Jason Orendorff <jason.orendorff at gmail.com>

> I think the simplest thing would be to replace [[Invoke]] with a
> [[GetMethod]] trap, and the idiom would then be exactly as above, but
> change `Get` to `GetMethod`.
>
> The last step of Invoke(O, P, args) would be replaced with:
>
>   6. Let method = O.[[GetMethod]](P, O).
>   7. ReturnIfAbrupt(method).
>   8. If IsCallable(method) is false, throw a TypeError.
>   9. Return method.[[Call]](O, args).
>
> For ordinary objects, [[GetMethod]] would be exactly like [[Get]]. The
> default proxy.[[GetMethod]] algorithm would be slightly different: it
> would return a bound function object, bound to the target.
>
> tomvc, I'm not sure why [[Has]] followed by [[Invoke]] is worse for
> double-lifting than [[Get]] followed by [[Call]], but this change
> would bring us back closer to the latter. Is that sufficient?
>

[[Has]] followed by [[Invoke]] would trigger 2 distinct traps on the
handler.
[[Get]] followed by [[Call]] only triggers the "get" trap on the handler.
The [[Call]] is made on the returned callable, it does not trigger the
handler's "apply" trap.
The point I was making is that using the current design, double-lifting
requires implementing only 1 trap.

Your proposed [[GetMethod]] would re-introduce the bound-function-per-call
overhead that the current [[Invoke]] design got rid of (see also my
downstream reply to Allen).

cheers,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130911/aa0ce008/attachment.html>


More information about the es-discuss mailing list