I've been thinking about inheritance a lot and need to braindump on it. Standard caveats: this is unpolished, first draft thoughts, not an expert, etc etc etc So, like, why, fundamentally, is inheritance so dangerous? And why is it so SUBTLY dangerous?https://twitter.com/johnregehr/status/1102777049599500289 …
Inheritance is about defining functions using partial information. Subclasses incrementally refine what information is available. Instantiating a class is declaring that this information is all there is, and the instance type is the least fixed point.
-
-
The square/rectangle problem is solved by most classes NOT defining slots, but only reader functions just like in CLOS. Only for concrete classes (Java "final") would you (auto) declare unfilled readers as slots. Or you could dispense with classes and keep refining prototypes.
-
Nix and Jsonnet also proved that prototype inheritance works beautifully in a pure lazy functional language. A proper type system for that style must support merging of slot sets, though, so multiple row variables with associative commutative unification. As in Ur, Ermine.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
Read my blog!