On __proto__ as a magical data property

Jason Orendorff jason.orendorff at gmail.com
Wed Jul 18 13:28:02 PDT 2012


On Tue, Jul 17, 2012 at 12:14 PM, Allen Wirfs-Brock
<allen at wirfs-brock.com> wrote:
> But I think that spec. largely reflects
> general agreement on other observable issues.
>
> In particular:
>       changing Object.prototype.__proto__ in any way disables the special
> __proto__ semantics for any object that inherits from itObject.prototype
>       Object.defineOwnPropertyobj, "__proto__", ...} does not modify
> [[Prototype]].  You have to use [[Put]] to do that

Thanks for taking the time to point these out.

It's funny, both of these points only have to be agreed and specified
at all if __proto__ is to be a data property. ES5 accessor property
semantics answer these questions in entirely boring, reasonable ways,
without resorting to new magic:

- changing Object.prototype.__proto__ disables the special __proto__
getter behavior iff you change the getter, and disables the special
__proto__ setter behavior iff you change the setter, simply because
per ES5 that's how accessor properties behave.

- Object.defineProperty(obj, "__proto__", {...}} doesn't modify the
[[Prototype]] simply because, per ES5, it doesn't call the setter.

-j


More information about the es-discuss mailing list