There are some places in the spec where we might use [[Invoke]], but don't:
- implicit .toString() and .valueOf() calls
(except Object.prototype.toLocaleString)
- implicit .toJSON() calls
- calls to Proxy handler methods
This seems unfortunate. Proxies with default handlers will work in
most places, thanks to the default [[Invoke]] trap, but not in ("" +
proxyObject) etc.
Is this still likely to change?
The apparent reason [[Invoke]] is not used in these places is that
they all do a [[Get]] first and check whether the property has a
callable value. But in the algorithm for yield*, in 14.4.1.2, we have
a similar check-before-calling situation, implemented using a
different idiom:
(step 4.d.viii in the last algorithm of 14.4.1.2)
> 1. If HasProperty(iterator, "throw") is true, then
> a. Let innerResult be the result of Invoke(iterator, "throw",
> (received)).
Having a [[GetMethod]] hook instead of an [[Invoke]] hook might make
it easier to use consistently everywhere.
-j
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss