extracting namespace from a property

Brendan Eich brendan at mozilla.org
Thu Mar 1 12:52:40 PST 2007


On Mar 1, 2007, at 7:01 PM, Yuh-Ruey Chen wrote:

> So a classes' prototype is always going to be mutable?

Yes.

> In chapter 9, I see "Prototype objects are always instances of the
> dynamic class Object and therefore can always be extended by the
> addition of dynamic properties. Unlike with function closures which  
> have

(Note to Francis: "function closures" here is wrong, it should be  
"function objects".)

> a prototype property that is a variable and can be reset to another
> object, classes have a prototype that is read-only and so always  
> points
> to the same object."
>
> which to me says that although the prototype property is read-only for
> classes, the referenced prototype object can still be mutated.

Right, when a property is described as read-only (or enumerable, or  
whatever), it's the attribute of the property (slot attribute, if you  
like), not the value (referent for an object type) that's being  
constrained.

> It only becomes an issue once a custom enumerable qualified  
> property is
> added by the author. So maybe we should let typeof name ===  
> "object" and
> just warn developers to use |is| if they intend to enumerate over
> objects with enumerable qualified properties.

Ok, that was my original position. Thinking about it, the only hazard  
is if one is migrating a large body of JS1 code to JS2, adding  
namespaced public properties to objects in the new code, but letting  
such objects flow into old code's for-in loops that assert or require  
typeof id == 'string'. We can make that a "fix as you find" case.

/be



More information about the Es4-discuss mailing list