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

Claus Reinke claus.reinke at talk21.com
Thu Jun 6 11:12:14 PDT 2013


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
http://clausreinke.github.com/
 


More information about the es-discuss mailing list