Subj : Re: finilize & construct: call disbalance To : anton muhin From : Brendan Eich Date : Fri Jul 09 2004 01:19 pm anton muhin wrote: > First of all, thank you for your explanation. > > Brendan Eich wrote: > >> When you call JS_InitClass, it creates a prototype object of your >> class, so that object will be finalized too. It won't be constructed, >> though -- you have to call the constructor yourself, if you need to. > > > Most class prototypes don't need to be constructed, but that means if > > JSCLASS_HAS_PRIVATE, JS_GetPrivate will return null for such objects, > > so your finalize implementation has to null-check. > > Does this follow the standard? The ECMA-262 standard doesn't govern the JS API. > > 13.2 Creating Function Objects > > > > 9. Create a new object as would be constructed by the expression new > Object(). > 10. Set the constructor property of Result(9) to F. This property is > given attributes { DontEnum }. > 11. Set the prototype property of F to Result(9). This property is given > attributes as specified in section 15.3.5.2. > > > So my reading is that by default prototype should be set to new Object. > Am I wrong? Eric Lippert from Microsoft seems to think so too (url: > http://blogs.msdn.com/ericlippert/archive/2003/11/06/53352.aspx ) Again, the standard there is specifying how to create function objects based on declarations in the language. Native class constructors can and must have prototype objects having [[Class]] other than "Object". This has been set in stone since 1995. See, e.g., the Option constructor in the DOM level 0. Change this and you break interoperation, at the limit. ECMA-262 explicitly does not govern such "host objects" and classes. /be .