accessing/modifiying getter and setter functions
Kris Zyp
kriszyp at xucia.com
Thu Apr 5 11:07:06 PDT 2007
Yes, I am aware the spidermonkey methods. However, IE has failed to take
Spidermonkey's lead yet on implementing these, I just was hoping ES4 would
mandate something like (or some equivalent) __define{G,S}etter__ and
__proto__, so that IE would someday provide these as well. In particular it
seems very unfortunate that there is no standard way to determine the
prototype of an object (__proto__). Sorry I am a little late with these
comments...
Kris
On 4/4/07, Brendan Eich <brendan at mozilla.org> wrote:
>
> On Apr 1, 2007, at 7:15 PM, Kris Zyp wrote:
>
> According to the spec, it is possible to define getters and setters for
> the properties. I am wondering if it is possible to access and modify the
> getter and setter for a property. Can I dynamically set the getter for an
> object?:
>
> obj.get x = function() { return 10; }
>
> Can I access the getter function/method?:
>
> myGetter = obj.get x;
>
> Or use the same getter for multiple properties?:
>
> obj.get y = obj.get x;
>
>
>
> The syntax wouldn't look like that (too error-like, prone to automatic
> semi-colon insertion), but something like SpiderMonkey's getter= and
> setter=, which are also available as __define{Getter,Setter}__ via
> Object.prototype could be done. SpiderMonkey as __lookup{G,S}etter__ too,
> as you requested ;-). But these are not proposed for ES4, they raise a few
> questions:
>
>
> * Under what conditions should it not be possible to replace an existing
> property via __defineGetter__ or __defineSetter__.
> * What's the best syntax, given that the old getter/setter= (and o = {p
> getter: function(){...}} etc.) pattern died around the time of ES3?
> * Any other gotchas?
>
>
> At this point we are deferring further work to a post-ES4 edition. I
> expect any proposal along the lines of __{define,lookup}{G,S}etter__ would
> be deferred too. It's conceivable that other implementations might copy
> SpiderMonkey's Object.prototype.__... methods in order to encourage
> standardization in the next ECMA edition.
>
>
> /be
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.mozilla.org/pipermail/es-discuss/attachments/20070405/fcce0dfd/attachment-0002.html
More information about the Es4-discuss
mailing list