Subj : Re: Property Getter & Setter Question To : Digital Man From : Brendan Eich Date : Sat Nov 20 2004 09:48 am Digital Man wrote: > Is there any advantage or disadvantage to setting this attribute (memory > consumption, performance, etc.)? Obviously, if there's no slot allocated for the property, then there's a memory savings. Slots are pointer-sized words allocated contiguously from the malloc heap, so if you have 100 getter/setter pairs and need no slots, then you can save 100 words (400 bytes on most platforms) per object. > If you have getter/setter functions for a > property, is there any reason that you *shouldn't* set this attribute? If the getter and setter want to see the last-got-or-set value in the *vp parameter passed in as well as out. A slot is a strong reference in the live thing graph the GC scans, provided the object owning the slot is alive. If you don't use a slot, and you want a reference to be stored for return by later gets, you will have to manage not only the storage for that reference (perhaps in a private data struct associated with the object via JS_SetPrivate), but you'll also have to make sure the reference is scanned by the GC (by implementing JSClass.mark). If you only ever store a translation of the value in a peer object space, and need no persistent JS value associated for future gets to return, then you need no slot. > I didn't know about this attribute as it's not documented at: > http://www.mozilla.org/js/spidermonkey/apidoc/sparse-frameset.html Patches welcome: mozilla/js/docs/jsref.xml. /be .