Hi,

In a the provided example, you assign a value. Can't you just use a getter/setter pair on the prototype chain? It sounds like it would solve your use case (without the syntax sugar). On ES5 - 8.12.5 step 4 & 5, the prototype chain is climbed to look up for an accessor and if there is a setter (anywhere on the prototype chain), this setter is called. Combined with the fact that a getter naturally do the same thing for getters, you have your way to change a value "directly on the prototype chain". Of course, if you want to change the property descriptor on the prototype chain, none of what I said apply.

David


Le 21/06/2011 17:24, Axel Rauschmayer a écrit :
As a loose analog to the prototype-chain-traversing getPropertyDescriptor(), I 
would still like to have something that allows one to easily *change* 
properties higher up the prototype chain (e.g. to use a prototype to share 
state).

Maybe it would be enough to just have Object.getDefiningObject(obj, propName):
http://www.mail-archive.com/es-discuss@mozilla.org/msg06652.html

But I can also imagine syntactic sugar:
         obj.foo := "abc"
desugars to
         Object.getDefiningObject(obj, "foo").foo = "abc"
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to