Subj : Re: Enumeration of extended properties of Array and Object prototypes To : netscape.public.mozilla.jseng From : Chris Zumbrunn Date : Sat Mar 27 2004 02:21 am NNTP-Posting-Host: adsl-212-90-218-6.cybernet.ch User-Agent: MT-NewsWatcher/3.3b1 (PPC Mac OS X) Xref: newsmst01.news.prodigy.com netscape.public.mozilla.jseng:8138 Brendan Eich writes: > Chris Zumbrunn wrote: > > > One real-world example that might serve well to illustrate what I mean > > would be getter/setter methods for data conversion of Javascript objects > > (for example to and from XML). > > If you mean someone calling Object.prototype.__defineGetter__('id', f), > or likewise for a setter, then the property that results in that case is > not enumerable in SpiderMonkey. > > This looks to me like a bug introduced when the old getter= form was > deprecated and its code copied into new __defineGetter__ and > __defineSetter__ methods of Object.prototype, as the getter= code > includes JSPROP_ENUMERATE among the attributes. But, you can take > advantage of it for now. I didn't know about __defineSetter__ and __defineGetter__ at all. I've had some trouble getting this to work in the environment where I use Spidermonkey - but that's just our embedding that will need to be fixed. > The problem hinted at by my last posting is that it's hard to change JS > now, given all the implementations; harder still, as you point out, to > change it in incompatible ways. Your best bet is to lobby ECMA people, > if you can contact them, about getting Edition 4 changed. Regarding ECMA4/JS2, I just found a list of changes Douglas Crockford suggests at http://www.crockford.com/javascript/recommend.html and "dontenum myClass.prototype.myMethod;" is on that list - I would think he sent these suggestions to the ECMA people. > Adding a way to define a non-enumerable property could be done in > SpiderMonkey -- is that something you could use well, or would you need > standard support to get other implementations to pay attention to the > change and implement the extension? No, I wouldn't need standard support. That's why I originally also asked if somebody had already done or attempted a patch of this kind in their implementations. However, I would also need a way of doing this in Rhino. Does Rhino provide anything similar to Spidermonkey's __defineSetter__ and __defineGetter__? Could a dontenum statement be added to both Spidermonkey and Rhino, even-though it isn't part of the ECMA specs (yet)? That would be ideal! Chris .