Hi David,

So basically the argument for removing the receiver argument is simply that
according to ES5 semantics, the "getPropertyDescriptor" trap, not "get" /
"set", should be called when proxies are encountered via prototype climbing
due to a [[Get]] or [[Put]].  If the pd returned by "getPropertyDescriptor"
contains a "get" (for [[Get]]s) or a "set" (for [[Put]]s), it will be
invoked with |this| bound to the receiver, and thus the receiver is in fact
available.  Thus, the "get" and "set" trap would only be invoked for own
property access, not inherited.  The reason you can't currently implement it
without the receiver argument is because the Firefox implementation calls
"get" and "set" instead of "getPropertyDescriptor".  Not sure what the V8
implementation does.

The other option would be to change from the ES5 semantics such that [[Get]]
and [[Put]] ([[Set]] ?) calls are propogated up the prototype chain, instead
of [[GetProperty]] calls, but I'm not sure what the ramifications of that
would be.

On Sun, Oct 16, 2011 at 6:00 PM, David Bruant <bruan...@gmail.com> wrote:

> Le 12/10/2011 15:38, David Bruant a écrit :
> > (...)
> >
> > _Future work_
> > 1) see how to deal with inherited events
> So, I've been working on that. Updated code at
> https://github.com/DavidBruant/HarmonyProxyLab/tree/master/EventedObject
> (index2.html for test case).
>
> Interestingly, in order to be able to implement inheritance, I used the
> receiver argument of the get trap. I know that it was very close to
> being removed completely [1], and that Firefox is incorrectly (according
> to the ES5 definition of [[Get]]) calling the get trap on the prototype
> but I'd like to argue to keep the receiver argument (exact traps to be
> defined though).
>
> As can be seen in my get trap, I use the 'receiver' argument for binding
> the event. I actually do not see any other way to implement it. I don't
> see a way for the event to know what to bind to when firing if the
> receiver isn't passed to a trap of the event when this one is on the
> prototype of the receiver.
>
> I'm not sure which trap should have this argument. I have showed one use
> case, but maybe others would need the receiver with the
> getPropertyDescriptor trap call recursively?
> To all traps related to inheritance?
>
> David
>
> [1] http://wiki.ecmascript.org/doku.php?id=strawman:proxy_drop_receiver
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>



-- 
Sean Eagan
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to