Readdition of __proto__

Andrea Giammarchi andrea.giammarchi at gmail.com
Mon Oct 14 13:32:40 PDT 2013


I meant that IIRC `obj["__proto__"]` should not invoke that Annex B
specified getter (@Benjamin, Annex B is where you'll find everything
related indeed) but `obj.__proto__` will ... unless once again I've missed
some update.

Yeah, I know that you link stuff, and glad you made some time for extra
clarification.

Cheers


On Mon, Oct 14, 2013 at 1:22 PM, Brendan Eich <brendan at mozilla.com> wrote:

> Andrea Giammarchi wrote:
>
> __Current Status__
>
>
> (Thanks for the dunders! :-P)
>
>
>  Instead of formalizing its form, ES6 accepted `Object.setPrototypeOf` as
> described in specs and decided to silently move beside, but still have in
> specs, the dunder `__proto__` form, fixing at least a couple of related
> gotchas so that:
>
>   * unless explicitly set as property, `__proto__` is a named property for
> every object that should not affect inheritance so that `obj["__proto__"]`
> or `obj[key]` where `key` is the string `"__proto__"` should not hot/swap
> the prototypal chain
>
>
> I'm not sure what you mean here, but first, __proto__ is not specified in
> ES6 drafts as an own property. See
>
> http://people.mozilla.org/~jorendorff/es6-draft.html#sec-B.2.2.1
>
> **
> B.2.2.1<http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-object.prototype.__proto__>Object.prototype.__proto__
>
> Object.prototype.__proto__ is an accessor property with attributes {
> [[Enumerable]]: false, [[Configurable]]: true }. The [[Get]] and [[Set]]
> attributes are defined as follows
>  ** B.2.2.1.1<http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-get-object.prototype.__proto__>get Object.prototype.__proto__
>
> The value of the [[Get]] attribute is a built-in function that requires no
> arguments. It performs the following steps:
>
>    1. Let *O* be the result of calling ToObject<http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-toobject>passing the
>    *this* value as the argument.
>    2. ReturnIfAbrupt<http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-returnifabrupt>
>    (*O*).
>    3. Return the result of calling the [[GetPrototypeOf]] internal method
>    of *O*.
>
> ** ** B.2.2.1.2<http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-set-object.prototype.__proto__>set Object.prototype.__proto__
>
> The value of the [[Set]] attribute is a built-in function that takes an
> argument proto. It performs the following steps:
>
>    1. Let *O* be CheckObjectCoercible<http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-checkobjectcoercible>
>    (*this* value)*.*
>    2. ReturnIfAbrupt<http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-returnifabrupt>
>    (*O*).
>    3. If Type<http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-ecmascript-data-types-and-values>
>    (*proto*) is neither Object or Null, then return *proto*.
>    4. If Type<http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-ecmascript-data-types-and-values>
>    (*O)* is not Object, then return *proto*.
>    5. Let *status* be the result of calling the [[SetPrototypeOf]]
>    internal method of *O* with argument *proto*.
>    6. ReturnIfAbrupt<http://people.mozilla.org/%7Ejorendorff/es6-draft.html#sec-returnifabrupt>
>    (*status*).
>    7. If *status* is *false*, then throw a *TypeError* exception.
>    8. Return *proto*.
>
> ** **
>
> /be
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131014/f1765cb2/attachment.html>


More information about the es-discuss mailing list