Implementing membranes using proxies, and [[GetInheritance]]

David Bruant bruant.d at gmail.com
Thu Sep 12 08:03:59 PDT 2013


Le 12/09/2013 15:35, Mark S. Miller a écrit :
> On Thu, Sep 12, 2013 at 4:14 AM, Tom Van Cutsem <tomvc.be at gmail.com 
> <mailto:tomvc.be at gmail.com>> wrote:
>
>     [+markm, allenwb]
>
>     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.
>
>
> agreed
>
>
>     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?
>
>
> yes.
Based on this new fresh agreement and assuming it sticks, the answer to 
Boris initial question changes a bit then:
if B.isPrototypeOf(A) and A' = new Proxy(A, handler), then the 
handler.getPrototypeOf can return any object (including B', a 
membrane-proxy to B) as long as A is extensible. If the code that runs 
against your membrane is not expected to be allowed to change 
extensiveness, you don't need a shadow target.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130912/c2587c4c/attachment.html>


More information about the es-discuss mailing list