inheriting statics

Brendan Eich brendan at mozilla.org
Sun Jan 7 11:40:02 PST 2007


On Jan 7, 2007, at 11:10 AM, zwetan wrote:

> quoting the doc
> "...
> This property is static in that it is specific to the class or
> function that you create. For example, if you create a class, the
> value of the prototype property is shared by all instances of the
> class and is accessible only as a class property. Instances of your
> class cannot directly access the prototype property.
> "

This seems misleading to me, since the "value of the prototype  
property" is an object that is not shared as if it were a static  
property value. Instead, the properties of the static prototype  
property are visible in all instances, unless overridden  
("shadowed").  So prototype is not an exception to the rule that  
static properties are not inherited by instances -- it's a different  
animal.

Also, function prototypes are not "static" in any sense (the proposed  
Function.apply static method is a class static in ES4; Date.parse is  
a static method in ES1-4; but Function.prototype is the prototype of  
the Function class/constructor -- it's different from f1.prototype  
and f2.prototype for two functions f1 and f2). Function prototypes  
are "instance variables" of each particular function object.

(I'm nit-picking the AS3 doc just so this doesn't get copied into the  
ES4 spec :-/.)

/be




More information about the Es4-discuss mailing list