Proxies: get+fn vs. invoke

Brendan Eich brendan at mozilla.com
Mon Oct 25 12:52:26 PDT 2010


On Oct 25, 2010, at 12:35 PM, Tom Van Cutsem wrote:

> 2010/10/20 Dmitry A. Soshnikov <dmitry.soshnikov at gmail.com>
> Anyway, is there an alternative how [[HasProperty]] can work correctly? I just though, that it's called by the "has" hook of a handler, which in turn can "lie" of course (i.e. return true when a property does not exist -- in such a case, noSuchMethod won't be called).
> 
> I think Dmitry is right: calling [[HasProperty]] on a proxy object should trigger its "has()" trap in the normal way, which should work with double lifting.

IIRC the problem is a meta level-shifter wants to implement just one trap, get in the absence of invoke. Would integration of noSuchMethod using has ("object detection") break this?

Anyway, the general issue before us is a least this choice:

* Either we stick with the current more minimal design, which besides being smaller also serves the goal of avoiding a method_missing (honey-)trap that tends to break JS's functional-programming, methods-can-be-extracted-and-passed-around-as-funargs-for-later-apply-usage, design win.

* Or we add noSuchMethod and satisfy the "just give me a new trap, I'll either use it well in method-only programs or make it work with has/get/etc." use-cases of Dmitry and others.

To reiterate something lest people get angry, this is not an easy trade, and I don't see anyone being rigid. It's simply a design decision we have to make one way or another.

Going into the process in TC39, as I noted previously, I did my best to argue for noSuchMethod. But having now written some proxy code, I'm much less concerned about the overhead of making a coherent proxy that has methods you can extract. That leaves me thinking the case of "just give me the method_missing trap" use-case is not worth the added weight. And Tom and Mark agree, and they are the champions of this proposal.

So can we let this stand for now and see how deployed Proxies in Firefox 4, beat on by real users who are willing to try them as spec'ed without noSuchMethod, fly with developers? That is one pretty good (albeit slow) way to get new data and insights.

Or we could keep arguing here, but I think we've gone around the same block more than once!

/be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20101025/cd9754db/attachment.html>


More information about the es-discuss mailing list