Subj : Re: Assigning to a nonexistent property To : netscape.public.mozilla.jseng From : Braden McDaniel Date : Thu Dec 09 2004 09:56 pm On Thu, 2004-12-09 at 11:09 -0800, Brendan Eich wrote: > Braden McDaniel wrote: > > I have defined a type whose JSClass::setProperty is simply > > JSPropertyStub. I would have expected an attempt to assign to a property > > on instances of this type (e.g., "instance.prop = foo") would result in > > an error message. > > Why? Because I'm not sufficiently familiar with the ECMAScript spec; and I haven't found SpiderMonkey documentation explaining otherwise. I suppose. > Stub means no-op, usually. Ah. Good to know. > And ECMA by default does not seal > objects, and stubs are for "most common" default cases. I didn't realize that wanting "instance.prop = foo" to be a no-op was a common case. Yeah... I bet that's not quite what you meant. I guess this is just how the machinery that propagates the call to a different property handler works? So why don't I eventually get a "object has no property 'prop'" error? > > Instead, I get no error message and the code seems to > > be a no-op. Is there something I should be doing to make this an error > > condition? (Aside from adding a setter that simply reports an error.) > > Do you want to seal the object against all future sets, adds, and > deletes? If so, consider JS_SealObject (beware passing true for the > |deep| param! ;-). Hm. That sounds useful. I'm not 100% sure yet if it's what I want in this case or not; but it sounds like a good tool to have. Thanks... -- Braden McDaniel e-mail: Jabber: .