do we have a thisclass? (for abstract static methods)

# Claus Reinke (12 years ago)

We do have this/super for references along the instance prototype chain, and we have this.constructor for getting to the class of an instance method. But what about getting the current class from a static method, for class-side inheritance?

// abstract
class Super {
   static f(x) { <thisclass>.g(x) } // how to write this?
   static g(x) { throw "abstract static method g" }
}

class Sub extends Super {
    static g(x) { console.log(x) } // how to call this from f?
}

Sub.f("how?")

The idea being that Super is partially abstract, with static f starting to work in subclasses once static g is properly implemented. How do I get the definition of static f in Super to pick up the definition of static g in Sub (without naming Sub explicitly, could be anywhere in the chain)?

I thought a solution for this had been discussed, but have no idea how to search for this in the list or spec.

Claus clausreinke.github.com

# Kevin Smith (12 years ago)

On Thu, Jun 6, 2013 at 2:12 PM, Claus Reinke <claus.reinke at talk21.com>wrote:

We do have this/super for references along the instance prototype chain, and we have this.constructor for getting to the class of an instance method. But what about getting the current class from a static method, for class-side inheritance?

Can't you just use "this"?

# Axel Rauschmayer (12 years ago)

On Thu, Jun 6, 2013 at 2:12 PM, Claus Reinke <claus.reinke at talk21.com> wrote: We do have this/super for references along the instance prototype chain, and we have this.constructor for getting to the class of an instance method. But what about getting the current class from a static method, for class-side inheritance?

Can't you just use "this"?

Exactly, that should work. The constructors form their own prototype chain (somewhat independently of the instance prototypes, but reflecting their chain), so everything should work out. In other words, Sub is just an object, so its methods can use this to refer to each other.

# Claus Reinke (12 years ago)

We do have this/super for references along the instance prototype chain, and we have this.constructor for getting to the class of an instance method. But what about getting the current class from a static method, for class-side inheritance?

Can't you just use "this"?

Exactly, that should work. The constructors form their own prototype chain (somewhat independently of the instance prototypes, but reflecting their chain), so everything should work out. In other words, Sub is just an object, so its methods can use this to refer to each other.

Kind of obvious from the desugaring... My thinking in that direction was blocked by associating wrong ideas with the class syntax.

Thanks, Claus

# Allen Wirfs-Brock (12 years ago)

On Jun 7, 2013, at 8:37 AM, Axel Rauschmayer wrote:

On Thu, Jun 6, 2013 at 2:12 PM, Claus Reinke <claus.reinke at talk21.com> wrote: We do have this/super for references along the instance prototype chain, and we have this.constructor for getting to the class of an instance method. But what about getting the current class from a static method, for class-side inheritance?

Can't you just use "this"?

Exactly, that should work. The constructors form their own prototype chain (somewhat independently of the instance prototypes, but reflecting their chain), so everything should work out. In other words, Sub is just an object, so its methods can use this to refer to each other.

Exactly, and super works too...

# Allen Wirfs-Brock (12 years ago)

On Jun 7, 2013, at 8:50 AM, Claus Reinke wrote:

We do have this/super for references along the instance prototype chain, and we have this.constructor for getting to the class of an instance method. But what about getting the current class from a static method, for class-side inheritance?

Can't you just use "this"?

Exactly, that should work. The constructors form their own prototype chain (somewhat independently of the instance prototypes, but reflecting their chain), so everything should work out. In other words, Sub is just an object, so its methods can use this to refer to each other.

Kind of obvious from the desugaring... My thinking in that direction was blocked by associating wrong ideas with the class syntax.

One reason I really resisted use of the keyword "static", in this context, but water and bridges...