[[Invoke]] and implicit method calls

Tom Van Cutsem tomvc.be at gmail.com
Tue Sep 10 03:58:06 PDT 2013

+1 for refactoring to use [[Invoke]] for most of these.

One reservation about the use of [[Invoke]] to call proxy traps (i.e.
functions on handler objects): the alternative pattern of first probing
with HasProperty destroys the "double lifting" pattern, which depends on
the proxy only ever performing 1 type of operation (a property access) on
its handler.

(double lifting is a pattern whereby the handler object is itself a proxy.
It allows you to write very generic proxies that only need to implement a
single "get" trap. See <
http://soft.vub.ac.be/~tvcutsem/invokedynamic/assets/proxies.pdf> section
4.5 for details.)

If we refactor to use [[HasProperty]] + [[Invoke]] to call traps, the
double lifting pattern requires implementing both the has() trap and the
get() trap. Not fatal, but I just want to point it out.


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

> On Mon, Sep 9, 2013 at 4:50 PM, Allen Wirfs-Brock <allen at wirfs-brock.com>
> wrote:
> > I'll take a look at it.  My first reaction is that this sounds like a
> good idea.
> A lot more can be found by searching for [[Call]]:
> - the call to @@toPrimitive from ToPrimitive (in 7.1.1)
> - the call to @@hasInstance from instanceofOperator (in 12.8.1)
> - the call to .toISOString from Date.prototype.toJSON (in
> - the call to .join from Array.prototype.toString (in
> - the call to .set from the Map constructor (in
> - the call to .add from the Set constructor (in
> and at that point I stopped looking.
> -j
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130910/7ad65c5c/attachment-0001.html>

More information about the es-discuss mailing list