David’s ProxyMap

Brendan Eich brendan at mozilla.org
Wed Oct 24 22:25:03 PDT 2012


Yehuda Katz wrote:
> On Wed, Oct 24, 2012 at 5:16 PM, Andrea Giammarchi 
> <andrea.giammarchi at gmail.com <mailto:andrea.giammarchi at gmail.com>> wrote:
>
>     But then why such "encouragement"
>     https://brendaneich.com/2012/10/harmony-of-dreams-come-true/ ? (
>     Proxy paragraph )
>
>     If __noSuchMethod__ is wrong, what's the point of suggesting a way
>     to simulate it through proxies?
>
>
> __noSuchMethod__ isn't the same problem as my concern about 
> invoke-only traps. In this case, (x = sink.bar).apply(sink) would 
> still hit the __noSuchMethod__ method.

That's right.

Andrea, please see especially this part of the blog post you cited:

"""
This implementation does not just call the |__noSuchMethod__| hook when 
a missing method is invoked, as shown after the |obj.bar()| line above. 
It also creates a thunk for any |get| of a property not in the target 
object and not in |Object.prototype|:

|js>  obj.bar
(function  (...args)  {
       return  receiver.__noSuchMethod__(name,  args);
     })
js>  var  thunk=  obj.bar
js>  thunk()
"bar"|

I think this is an improvement on my original 
<https://bugzilla.mozilla.org/show_bug.cgi?id=196097> |__noSuchMethod__| 
creation all those years ago in SpiderMonkey.
"""

/be


More information about the es-discuss mailing list