Implementing membranes using proxies, and [[GetInheritance]]

Tom Van Cutsem at
Wed Sep 11 07:17:14 PDT 2013

2013/9/11 David Bruant <bruant.d at>

> Le 11/09/2013 06:10, Boris Zbarsky a écrit :
>  Hey all,
>> I was looking at implementing a membrane using ES6 proxies and ran into a
>> snag.  Consider a situation where object A has prototype B.  A' is a proxy
>> implementing the membrane, whose target is A.
>> But now if Object.getPrototypeOf(A') is invoked the return value will be
>> B (unless it just throws).  There's no way for A' to return a new proxy B'
>> whose target is B in this situation.
> In essence yes. In practice, you can do:
>     // trap:
>     getPrototypeOf: function(target){
>         target.__proto__ = B';
>         return B';
>     }
> But of course, it changes A [[Prototype]], which is probably not
> desirable. And of course, although to-be-standard, __proto__ is bad taste...

Indeed, this is also the pattern I used, except it doesn't set the
`__proto__` of the real target, but of a shadow target: <

Setting `__proto__` may be bad taste in general, but this is a case where
using this capability is necessary.

Ps: btw, wasn't "GetInheritance" supposed to be renamed "GetPrototype"?

I think we had agreement on that. Allen?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list