inheriting statics

zwetan zwetan at gmail.com
Tue Jan 9 09:15:07 PST 2007


> My motivation is to keep the door open for a mix-in, where the
> superclass(es) could be different for different concrete classes.
> But it also would make refactoring easier if I could move a static
> property to a different superclass and not have to update all uses of
> it in subclasses.

but we already got that in ES4/AS3

class A
    {
    static var foobar:String = "foobar";
    ...
    }

class B extend A
    {

   public function test():String
       {
       return foobar; //you can access the static
       }
    }


------------------------

class A
    {
    ...
    }

class B extend A
    {

    static var foobar:String = "foobar"; //you can move its defintion

   public function test():String
       {
       return foobar;
       }
    }

------------------------


so where is the problem really ?


do you want to be able to access the static inherited like that:

trace( A.foobar );

and if class B extend A
trace( B.foobar );
even if static foobar is defined in class A ?

zwetan



More information about the Es4-discuss mailing list