inheriting statics

P T Withington ptw at pobox.com
Sun Jan 7 12:23:40 PST 2007


On 2007-01-07, at 14:32 EST, Brendan Eich wrote:

> On Jan 7, 2007, at 9:50 AM, Peter Hall wrote:
>
>> "Since inheritance does not apply to static members"
>>
>> Your assumption is what I was questioning. Why doesn't inheritance
>> apply to static members?
>
> Right, the assumption should be justified.  One rationale is by  
> extension of ES1-3 (plain ol' JS):

[...]

> Inclusion of statics in the scope chain within instance methods is  
> a convenience afforded by the new special form of methods defined  
> via function definitions nested in a class definition. But it's not  
> inheritance.

One could still ask, "should _classes_ inherit static properties of  
their superclass?"  Should the statics of my superclass be in my  
scope chain?  Should statics of an instance's superclass be visible  
in the instance's constructor?

class Foo {
   static const ZOT = 42;

   function zotValue() {
     return this.constructor.ZOT;
   }
}

class Bar extends Foo {
   function improvedZotValue() {
     return this.constructor.ZOT + 1;
   }
}





More information about the Es4-discuss mailing list