[[Invoke]] and implicit method calls

Till Schneidereit till at tillschneidereit.net
Wed Sep 11 04:17:01 PDT 2013


On Wed, Sep 11, 2013 at 4:44 AM, Brendan Eich <brendan at mozilla.com> wrote:

> Except http://ariya.ofilabs.com/2011/**08/hall-of-api-shame-boolean-**
> trap.html<http://ariya.ofilabs.com/2011/08/hall-of-api-shame-boolean-trap.html>
> .
>

So one thing we could potentially do is to say that a proxy trapping
[[Invoke]] either always returns  [invokeSuccess, result] and doesn't need
the boolean argument - or it's just never conditional: if you trap
[[Invoke]], you have to serve all method calls, and Proxy.[[Invoke]] would
just return result. Given that proxies users would most likely not be used
for these corner cases in the majority of cases, and quite deliberately so
in the others, this seems fine to me.

>
> /be
>
>
> Till Schneidereit wrote:
>
>>
>>     I'm beginning to like a conditional option on [[Invoke]].
>>
>>     Consider: [[Invoke]](P, ArgumentsList, Receiver, conditional=false)
>>
>>     If conditional is false, it works just like the current [[Invoke]]
>>     spec.
>>
>>     If conditional is true and the [[Get]] value is not callable (this
>>     includes undefined for a missing property) result is: [false,
>>     [[Get]] result].
>>     if conditional is true and the [[Get]] value is callable, result
>>     is [true, value returned from [[Call]]
>>
>>     The conditional form would only be used  in odd cases like the
>>     toJSON call.
>>
>>     ES code can accomplish the same thing via Reflect.invoke with true
>>     as the 4th argument.
>>
>> I like it. This gets around the issue of distinguishing a return value of
>> `undefined` from "no callable property with that name found" and would be
>> easy to implement for proxies, too.
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130911/0f1be3e1/attachment.html>


More information about the es-discuss mailing list