[[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
(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 <
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>
> > 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 188.8.131.52)
> - the call to .join from Array.prototype.toString (in 184.108.40.206)
> - the call to .set from the Map constructor (in 220.127.116.11)
> - the call to .add from the Set constructor (in 18.104.22.168)
> and at that point I stopped looking.
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss