do we have a thisclass? (for abstract static methods)
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"?
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.
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
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...
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...
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?
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