Subj : Re: finilize & construct: call disbalance To : anton muhin From : Brendan Eich Date : Wed Jul 14 2004 12:07 pm anton muhin wrote: > Brendan Eich wrote: > >> Why do you insist on wanting an object of class "Object" as the >> prototype? That's neither required by the spec (except for the >> RegExp.prototype, which I claim is a bug in the spec), nor is it >> required for compatibility with existing SpiderMonkey native and host >> classes (which indeed want their class prototype objects to be of the >> class whose instances delegate to those prototype objects). > > Because I don't see any reason for the prototype to be of the same class > as instances. I suppose that I just understand prototype poorly :( The prototype is just the first, and "representative" object of the class. All instances after it delegate to it. Why should it not be of the same class as those instances? In fact if it is to have shared properties such as methods defined once as its properties, then it may need class-specific [[Get]] and [[Put]] behavior (SpiderMonkey's JSClass.getProperty, JSClass.setProperty). It makes less sense to insist that the prototype be a plain Object. > Another reason, but technical one, is that I don't want to check if my > object has private data. It's not laziness, but rather I try to make > things as clean as possible. Then give the prototype private data too, by calling your constructor on it after the return from JS_InitClass. > jsemit.c(2716) : warning C4244: '=' : conversion from 'unsigned long ' > to 'unsigned short ', possible loss of data Thanks, this will be fixed in the 1.8a3 trunk soon. /be .