[[Invoke]] and implicit method calls

Jason Orendorff jason.orendorff at gmail.com
Tue Sep 10 08:20:41 PDT 2013

On Tue, Sep 10, 2013 at 6:31 AM, Domenic Denicola
<domenic at domenicdenicola.com> wrote:
> Note that determining desired pattern is relevant to the new DOM promises design (tracking this at https://github.com/domenic/promises-unwrapping/issues/25). Omitting a few steps not relevant to the issue under discussion, currently we do:
> - Let `then` be `Get(potentialThenable, "then")`.
> - If `IsCallable(then)`, call `then.[[Call]](potentialThenable, (resolve, reject))`.
> It seems like we'd want to apply the same logic here as we do to `valueOf` etc., which is what I tried to model this after.

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?


More information about the es-discuss mailing list