B.3.1 The __proto__ pseudo property

Brendan Eich brendan at mozilla.com
Sun Apr 21 11:38:18 PDT 2013


Allen Wirfs-Brock wrote:
> On Apr 21, 2013, at 10:03 AM, Brendan Eich wrote:
>> Allen Wirfs-Brock wrote:
>> This isn't what we seemed to agree on at past TC39 meetings.
>>
>> It's also not what the engines trying to converge on ES6 semantics have implemented.
>
> It's not clear to me, yet what convergence we actually have.

Read the meeting notes to remind yourself:

https://mail.mozilla.org/pipermail/es-discuss/2013-February/028631.html

Look for

BE: (Review of latest changes to __proto__ in Firefox)

and read on.

> Regardless, it's only observable via Object.getOwnPropertyDescriptor(Object.prototype, "__proto__") which in my proposal returns undefined when Dunder proto is active and in other proposals returns a function that when evaluated throws something.

No. From those notes:

EA: Throws if called with object and setter coming from different realms
>    The semantics of Dunder proto that have been discussed isn't just  that of an accessor property and can't be purely implemented as such so I no value in trying to masquerade it as an accessor for getOwnPropertyDescriptor.  Returning get/set functions that always throws is just adding complexity that delivers no value.

The proposal we've discussed does no such thing. What's implemented in 
JSC, SpiderMonkey, V8 does no such thing.

js> var d = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__')
js> d
({configurable:true, enumerable:false, get:function () {
     [native code]
}, set:function () {
     [native code]
}})
js> var o = {}
js> d.get.call(o)
({})
js> d.get.call(o) === Object.prototype
true
js> d.set.call(o, null)
js> d.get.call(o)
null

The censorship requires a realm-check. That seems (and seemed, to TC39 
in January) better than a wart in Object.getOwnPropertyDescriptor that 
turns a blind eye to the existence of '__proto__' in Object.prototype in 
contradiction to plainly observable facts!

/be


More information about the es-discuss mailing list