Subj : Re: custom class definition question To : netscape.public.mozilla.jseng From : Brendan Eich Date : Tue Jul 20 2004 09:16 am Brendan Eich wrote: > But almost always, when defining properties with tinyids, you don't want > each object to have its own copy of the property shadowing the prototype > property. That's wasteful of memory without any benefit. Tinyids exist > for fast dispatching in shared class getters and setters, based on > prototype properties that don't need to be shadowed (that in fact may > want to have JSPROP_SHARED among their attributes, if they are not > JSPROP_READONLY). In case it is not clear, resolve is called for each object along the prototype chain, starting from the directly-referenced object, so long as the id being accessed is not defined in each object. So if you have an instance o whose prototype, o.__proto__, is p, and p has tinyid-defined properties that you wish to share rather than shadow, then you don't want to do anything when resolve is called on o. Let its caller, js_LookupProperty, walk up the prototype chain to p, where it will find the tinyid-defined properties. Only if each instance o that delegates to p needs its own copy of a property, perhaps to hold specific attributes, or to have its own slot for property value storage (in which case, do not use JSPROP_SHARED), or for a custom getter/setter that are specific to that property, do you want to define the property in o. /be .