At the last TC39 meeting, an agreement was reached for proxies to support an Invoke trap. I'm currently implementing this trap in SpiderMonkey[1] and realized that there's one conceptual issue that has to be decided in the spec:
Currently, the [[Get]] trap naturally handles method calls on the proxies, as these are gets followed by calls to the returned function value. With proxies also being able to trap [[Invoke]], things become less clear, with four possible options: 1. for method calls, only the [[Invoke]] trap is called 2. if an [[Invoke]] handler exists, it is called, otherwise a [[Get]] handler is called, if that exists 3. like 2., but additionally, if the [[Invoke]] handler doesn't return a callable value, the [[Get]] handler is called 4. like 3., but with reserved order of handler invocation: if a [[Get]] handler exists, it is called. If the result isn't callable, or [[Get]] isn't handled, an [[Invoke]] handler is called, if one exists The first of these options seems conceptually cleanest to me, but I do think that the other options (perhaps except for the last one) can be argued for to some extend, too: the abstract operation `Invoke`, via its step 5, `GetMethod`, contains a call to the [[Get]] operation, after all. [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=878605
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

