News for hackers. Stuff that matters.
Re:Inheritance Often Doesn't Make Sense by kaoD on Saturday March 17, 2018 @08:34AM (#16606684)
This matches my experience: ontological inheritance gets in the way. What we actually want is traits. What can something do, not what it is.
Re:Inheritance Often Doesn't Make Sense by weberc2 on Saturday March 17, 2018 @09:46AM (#16606899)
This seems like structural subtyping? Are these synonyms?
Re:Inheritance Often Doesn't Make Sense by kaoD on Saturday March 17, 2018 @11:35AM (#16607400)
I think traits (as I know them) are still nominal subtyping. E.g.: a Rust struct implementing a next() method does not implement the Iterator trait even if they are structurally equivalent. You have to explicitly implement the trait.
Re:Inheritance Often Doesn't Make Sense by kazagistar on Saturday March 17, 2018 @12:18PM (#16607596)
More like interfaces. A lot of OOP languages just did it in a limited way where interfaces for a class are closed. Meanwhile in Haskell or Rust, you can define your interfaces, and then provide implementations of it for existing objects like String. Or the Scale workaround, which basically is implicitly converting to wrapper classes that implement the interface. With the goal being extending existing types with new shared behavior, without the limitations of full inheritence.
Re:Inheritance Often Doesn't Make Sense by steveklabnik on Saturday March 17, 2018 @12:05PM (#16607553)
The only sub typing in Rust is lifetimes; other types have no sub typing.

Traits are “ad hoc polymorphism”.