Implementing membranes using proxies, and [[GetInheritance]]

Mark S. Miller erights at google.com
Thu Sep 12 08:36:34 PDT 2013


Membranes need shadow targets, because of non-extensibility of objects and
non-configurability of properties. This special case of
no-invariants-anywhere is not JavaScript. Trying to do membranes without
shadow targets is a useless exercise.


On Thu, Sep 12, 2013 at 8:03 AM, David Bruant <bruant.d at gmail.com> wrote:

>  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>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
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130912/8ed838e9/attachment-0001.html>


More information about the es-discuss mailing list