extracting namespace from a property

Jeff Dyer jodyer at adobe.com
Thu Mar 1 13:44:56 PST 2007

> -----Original Message-----
> From: es4-discuss-admin at mozilla.org
[mailto:es4-discuss-admin at mozilla.org]
> On Behalf Of Francis Cheng
> Sent: Thursday, March 01, 2007 1:02 PM
> To: es4-discuss at mozilla.org
> Subject: RE: extracting namespace from a property
> You may have gotten that impression from the old Netscape ES4 spec,
> circa 2003, which agrees with the scenario you describe.
> We have not yet posted this to the wiki, but AFAIK, the current
> is to have dynamic *not* inherited. This is the way ActionScript 3.0
> implemented dynamic classes, i.e. the dynamic attribute is not
> inherited. Maybe someone else can chime in with the rationale as I
> remember (or I never knew).

You are correct -- the dynamic attribute is not inherited in AS3. As
Brendan points out sealedness is an attribute of instance values, so at
least that part of the meaning of 'dynamic' is independent of
inheritance. The other meaning, in strict mode, that references through
an object of a dynamic class are not checked, is a little more
troublesome. But you have this problem anyway if you special case class
Object as was done in AS2 and Netscape-JS2.

This is one of those design decisions that we debated at length and in
the end chose the least of various imperfect alternatives, which
included the two mentioned here and others involving additional
attributes to separate out the various meanings of dynamic. In the end
we chose to minimize special cases, and prefer sealedness to
unsealedness. We didn't want to treat class Object specially, and we
wanted to make the programmer ask for dynamic if he wants it.

> -----Original Message-----
> From: es4-discuss-admin at mozilla.org
> [mailto:es4-discuss-admin at mozilla.org] On Behalf Of Peter Hall
> Sent: Thursday, March 01, 2007 12:44 PM
> To: Yuh-Ruey Chen
> Cc: Brendan Eich; es4-discuss at mozilla.org
> Subject: Re: extracting namespace from a property
> > > IIRC you are allowed to have a dynamic subclass of a non-dynamic
> > > superclass (Jeff correct me if I'm wrong). dynamic is not
> > > and applied to a class, it affects only mutability of instances
> > > (whether one can add "expandos", i.e. whether the class "seals"
> > > instances), again if my memory is correct. Others should correct
> > > or add more information as needed.
> > >
> I can't see it in the spec, but I was under the impression that, in
> general, dynamic *is* inherited, but Object is made a special
> exception to avoid making every object being dynamic. This is
> important because any code that relies on the fact that an object is
> dynamic (including the class itself) would break if the object turned
> out to be an instance of a subclass that didn't declare itself
> dynamic.

Class objects are always unsealed for compatibility with ES3 constructor
functions. Code that expects an instance to be unsealed needs to know
what kind of instance it is. The only way to know for sure by looking at
the type of a reference is if that type is of a class that is final and

Hope that helps,

More information about the Es4-discuss mailing list