...In more prosaic terms, this means that static methods are not inherited.I'd be interested to hear more details about the issues with that approach. I've not had any problems with it, and occasionally found it useful. For example, in one situation I needed a hierarchy of static constructors that matched the hierarchy of instance constructors.
[0] Ruby also has "the meta-metaclass hierarchy matches the metaclass hierarchy" and "the meta-meta-metaclass hierarchy..." ad infinitum. It's a beautiful design really - it means that in Ruby (unlike Smalltalk), it's always true that "the superclass of the metaclass is the metaclass of the superclass".
Edit: Here's the quote I was remembering:
> My hunch is that we don't want metaclass inheritance. From talking to a few old Smalltalkers, they generally consider it a mistake there. Also, Java, C++, C#, etc. have semantics more similar to not allowing metaclass inheritance (in other words, static methods aren't inherited), and it seems to work well there.
https://groups.google.com/g/wren-lang/c/LkKg51fEUg4/m/0GOK0P...
class A {
construct new () {}
thing(obj) {
…
}
}
class B is A {
construct new () {}
}
B.new().thing(obj)
I’ll need to test this as this is what I want from my scripting language. If this works than wren will replace my Lua janky scripting. class A {
name {
_name
}
name=(value){
_name=value
}
construct new () {
_name = "hello"
}
thing() {
System.print(name)
}
}
class B is A {
construct new () {}
update(name){
super.name = name
return this
}
}
var b = B.new()
b.update("world").thing()
If you change System.print(name) to System.print(_name) it works but it doesn’t when using the getter. You get null when System.print(name) is called.Same if you use this.name
The getter either needs to be (exactly) `name { _name }` or it needs to explicitly `return _name`.