[[Invoke]] and implicit method calls

Allen Wirfs-Brock allen at wirfs-brock.com
Tue Sep 10 09:16:59 PDT 2013

On Sep 10, 2013, at 5:15 AM, Till Schneidereit wrote:

> On Tue, Sep 10, 2013 at 1:31 PM, 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 guess for this case as well as for all or most of those Jason mentioned, something like [[MaybeInvoke]] is required. I.e., a version of the [[Invoke]] internal method[1] that has step 5 replaced by "If Type(method) is not Object, return undefined".
> Sections and 9.3.11 would have to be dealt with similarly, by introducing non-typeerror-throwing [[MaybeInvoke]] versions.

However, it appears that using that approach you can't distinguish between a missing/non-callable property value and  a method invocation that actually returned undefined.

I think if we had [[MaybeInvoke]] we would have to define it so that we could make that distinction.  Perhaps by returning a a tuple [success, value]

However, I think the [[InvokeFunction]] is a better solution.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130910/34d67b68/attachment.html>

More information about the es-discuss mailing list