inheriting statics

Peter Hall peterjoel at gmail.com
Tue Jan 9 09:15:12 PST 2007


Right. So to access a static method of a super-class, where you have
shadowed it with another method, you must access it via the class
name..

I could see this leading to errors, since the override attribute would
not be used in this context. The same errors could equally happen with
the existing ES3 scoping rules.

Is that an argument against inheriting?

Peter

On 1/9/07, Jeff Dyer <jodyer at adobe.com> wrote:
> In AS3 and draft ES4 'super', like 'this', resolves to a value of an
> instance type, and so in your example below the static foo in A will not
> be found by 'super.foo()'.
>
> And yes, the definition of foo as a static in class A and an instance
> method in class B is allowed. In fact, a static and instance definition
> in the same class with the same name is allowed. They appear in
> different scopes.
>
> Jd
>
> > -----Original Message-----
> > From: es4-discuss-admin at mozilla.org
> [mailto:es4-discuss-admin at mozilla.org]
> > On Behalf Of Peter Hall
> > Sent: Tuesday, January 09, 2007 8:16 AM
> > To: Dave Herman
> > Cc: Neil Mix; P T Withington; Brendan Eich; Nicolas Cannasse; es4-
> > discuss at mozilla.org
> > Subject: Re: inheriting statics
> >
> > >
> > > In other words, statics are inherited and can be redefined, although
> > > they are statically resolved, so they have shadowing semantics (like
> > > instance fields) rather than overriding.
> > >
> >
> >
> > So there does not even need to be a requirement that the type of
> > static variables be related to the type of the variable in the
> > super-class, or for static method signatures to match.
> >
> > But I'm wondering..
> >
> > class A {
> >  public static function foo (){
> >  }
> > }
> >
> > class B extends A {
> >    // should this non-static method be allowed?
> >    public function foo(){
> >        // and, if so, can I do this?
> >        super.foo();
> >    }
> > }
> >
> > class C extends B {
> >   public static function foo(){
> >       // and, if so, would this invoke A.foo or be an error?
> >       super.foo();
> >   }
> > }
> >
> >
> > Peter
> > _______________________________________________
> > Es4-discuss mailing list
> > Es4-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es4-discuss
>



More information about the Es4-discuss mailing list