On Sun, 19 Dec 2010 22:19:25 +0100, Juriy Zaytsev <kan...@gmail.com> wrote:

On Sun, Dec 19, 2010 at 7:21 AM, Lasse Reichstein <
reichsteinatw...@gmail.com> wrote:

Also, it provides a feature that ES5 doesn't yet: the ability to change an object's prototype chain. ES5 brought us Object.getPrototypeOf, but no
setPrototypeOf.


This was a conscious decision, as far as I know. Mutable [[Prototype]]
carries performance overhead. I think that was one of the concerns of some
of the TC-39 members. Mutable [[Prototype]] via "__proto__" also breaks
other things. IIRC, there was a bug in V8 where JSON.stringify({ __proto__:[] }) serialized to "[]". This wouldn't happen with `Object.setPrototypeOf` but performance would still be an issue, I suppose.

It's there now, so performance won't be any worse than today.
Personally, I think the cost of a mutable prototype is subsumed in the cost
of having mutable objects in the prototype chai. You still have to check the
entire prototype chain every time you make a lookup.
(The V8 bug sounds like just a bug, using instanceof to check for being an
array instead of checking [[Class]] - but that's guessing, I don't remember
that bug.)

I would love to see __proto__ go, if only to not have to special-case the
__proto__ property on every object - and not have any properties that exist
implicitly on all objects. I doubt it will happen until there are suitable
replacements. Even if setPrototypeOf isn't really necessary, __proto__ also
serves as a substitute for the missing analogues of Object.create, e.g.,
an Array.create that creates an array object with a given prototype (and ditto
for all the other [[Class]] values).

...
Well, Mozilla has already deprecated magic __count__, then removed it from FF4. I can imagine them removing __proto__ (or issuing a warning on
access/assignment) under strict mode. Other implementations could be more
problematic.

If anyone will go first in removing it, I think it will be Mozilla. They seem
more willing to take chances than the other browser vendors.

/Lasse

--
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to