Approach of new Object methods in ES5

Asen Bozhilov asen.bozhilov at gmail.com
Fri Apr 16 12:23:29 PDT 2010


2010/4/16, Brendan Eich <brendan at mozilla.com>:
> On Apr 16, 2010, at 7:18 AM, Asen Bozhilov wrote:

Special thanks for your response!

>> Especially when I want to change only [[Prototype]] and keep values of
>> other internal properties and methods for that object.

> I write this having designed and implemented settable __proto__ over
> 12 years ago. At the time, unstratified metaprogramming APIs were
> popular; if it was good enough for Python, why not for JS. But the
> lack of stratification is a problem (consider JSON data with a key
> "__proto__").
> And worse, the mutability means implementations must
> check for cyclic prototype chains in order to avoid ilooping.
>
> Mutable __proto__ also makes optimization harder, or simply defeats
> optimizations at the price of some complexity in the engine.

I agree with your attentions. For example, I ever wonder how you treat
identifier with name `__proto__`. Perhaps that depend on
implementation of Activation/Variable object.

(function () {
    var __proto__ = {x : true};
    print(x);
})();

If VO is implemented as native object, that code will pollute Scope
Chain and `x' will be resolve from VO[[Prototype]] during identifier
resolution.



More information about the es-discuss mailing list