[[Invoke]] and implicit method calls

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Sep 11 15:44:48 PDT 2013

On Sep 11, 2013, at 3:07 PM, Brendan Eich wrote:

> Allen Wirfs-Brock wrote:
>>>> 1) The [[Invoke]] operation is meant to primarily trap method calls generated by user-code of the form |obj.m(...args)|. This is by far the most common case, and I believe we should not extend [[Invoke]] with additional arguments that are irrelevant to this primary use case. Rather than having a boolean argument, better to statically separate the cases into two separate internal methods.
>>> +a bazillion. Srsly!
>> I'm not sold.  Two internal methods
> Which two?
> We had [[Get]]. We add [[Invoke]]. Or do you mean a different two?

what Tom was referring to above: "statically separate the cases into two separate internal methods".

I presume, in context, he means [[Invoke]] and [[ConditionalInvoke]] but it could also mean [[Invoke]] and [[InvokeFunction]]

[[Invoke]] internally does [[Get]]+[[Call]], throws if method is missing or not callable
[[ConditionalInvoke]] internally does [[Get]]+if method callable [[Call]], it doesn't throw if method is missing or not callable
[[InvokeFunction]] internally does a [[Call]] and is called after an external [[Get]], so [[Get]] + [[InvokeFunction]] is normal usage.  

All of the possible [[*Invoke*]] forms are passed both the Proxy and the target as arguments (along with the call arg list) and may remap the this value or arguments that are passed to the actual function call. 

Calling a method, only if it exists or only if the property value is callable can be accomplished via:
[[ConditionalInvoke]] or [[Get]]+[[InvokeFunction]]

[[Get]]+[[Invoke]] is bad because it normally will do two [[Get]] calls for the property.

Having both [[Invoke]] and [[ConditionalInvoke]] or [[Invoke]] and [[InvokeFunction]] means that handlers must duplicate invocation handling in two places.

Combining [[Invoke]] and [[ConditionalInvoke]] into a single operation is possible via parameterization and would eliminate the duplication
[[Invoke]] could be eliminated and we only have [[InvokeFunction]]


More information about the es-discuss mailing list