David Bruant (2013-09-11T15:02:04.000Z)
Le 11/09/2013 16:22, Tom Van Cutsem a écrit :
> 2013/9/11 David Bruant <bruant.d at gmail.com <mailto:bruant.d at gmail.com>>
>
>     I think it was discussed at some point to get rid of the
>     restriction on the getPrototypeOf trap and enforce it only for
>     non-extensible objects (but I can't find the info anymore, I might
>     just be inventing this...). It would allow you to return a
>     different object assuming the target is and remains extensible
>     (more on that below).
>
>
> No, I think you're confusing with an invariant on [[SetInheritance]]. 
> Basically [[SetInheritance]] has no invariants as long as the object 
> is extensible. If it is non-extensible, then proxies enforce that the 
> prototype of proxy and target are the same, see 
> <https://people.mozilla.org/~jorendorff/es6-draft.html#sec-9.3.2 
> <https://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-9.3.2>>.
oh ok.

> [[GetInheritance]] always checks whether the proxy and target's 
> prototype are the same, but as you pointed out, if the target is 
> extensible, you can set its prototype to some other object before 
> returning a value from the getPrototypeOf trap.
It's annoying to cleanup post-trap though (to restore the target initial 
prototype). Is the invariant on getPrototypeOf that important on 
extensible objects?
I think it is the only trap that enforces something without a related 
eternal invariant.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130911/9ec80537/attachment.html>
domenic at domenicdenicola.com (2013-09-25T01:41:24.263Z)
Le 11/09/2013 16:22, Tom Van Cutsem a écrit :

> No, I think you're confusing with an invariant on [[SetInheritance]]. 
> Basically [[SetInheritance]] has no invariants as long as the object 
> is extensible. If it is non-extensible, then proxies enforce that the 
> prototype of proxy and target are the same, see https://people.mozilla.org/~jorendorff/es6-draft.html#sec-9.3.2.

oh ok.

> [[GetInheritance]] always checks whether the proxy and target's 
> prototype are the same, but as you pointed out, if the target is 
> extensible, you can set its prototype to some other object before 
> returning a value from the getPrototypeOf trap.

It's annoying to cleanup post-trap though (to restore the target initial 
prototype). Is the invariant on getPrototypeOf that important on 
extensible objects?
I think it is the only trap that enforces something without a related 
eternal invariant.