Implementing membranes using proxies, and [[GetInheritance]]
allen at wirfs-brock.com
Thu Sep 12 08:42:05 PDT 2013
On Sep 12, 2013, at 6:35 AM, Mark S. Miller wrote:
> On Thu, Sep 12, 2013 at 4:14 AM, Tom Van Cutsem <tomvc.be at gmail.com> wrote:
> [+markm, allenwb]
> 2013/9/11 David Bruant <bruant.d at gmail.com>
> Le 11/09/2013 16:22, Tom Van Cutsem a écrit :
>> [[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.
> For membranes, when using a shadow target, there's no need to clean-up/restore anything.
> But more generally, you're right that it's odd [[GetInheritance]] is doing an invariant check on an otherwise extensible/configurable object. I think it's simply a remnant of the time before we fully embraced setPrototypeOf.
> Now that Object.setPrototypeOf is part of ES6, there doesn't seem to be a point in guaranteeing the stability of Object.getPrototypeOf for extensible objects.
> The important invariant is that getPrototypeOf remain stable for non-extensible objects.
> Hence, it seems we could replace steps 8-10 of Proxy.[[GetInheritance]] <https://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-9.3.1> with:
> 8. Let extensibleTarget be the result of IsExtensible(target).
> 9. ReturnIfAbrupt(extensibleTarget).
> 10. If extensibleTarget is true, then return handlerProto.
> // steps below identical to the old steps 8-10:
> 11. Let targetProto be the result of calling the [[GetInheritance]] internal method of target.
> 12. ReturnIfAbrupt(targetProto).
> 13. If SameValue(handlerProto, targetProto) is false, then throw a TypeError exception.
> Mark, Allen, does that seem right?
Also, seems right to me.
That sounds like sufficient consensus. I'll make the change to the spec.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss