this toot inspired by my realising php doesn't support return type covariance and will crash out fatally if you try to do covariant things with return types, even though it has a keyword (self) that appears to be specifically intended for doing covariant things with return types
it turns out c♯ also does not support return type covariance
so c♯ sucks actually
@AdrienneCohea sure! here's the simplest possible case:
class Base {
public Base getSelf() {
return this;
}
}
class Derived extends Base {
public Derived getSelf() {
return this;
}
}
this is well-typed from a theoretical perspective, and it typechecks in java and scala, but not in in c♯
@00dani Ah okay... Huh... I guess I haven't had a need for it. I'm sorry the language lacks that feature that you need :(
Does Rust have such a thing?
@AdrienneCohea good question! rust has an excellent type system so i'd kind of expect it to, but iirc it doesn't really do traditional subclassing so the situation mightn't come up?
i suspect the closest equivalent in rust would work. not sure 