4 ms·
>ADTs are the obvious choice but somehow in 2021 most people are using languages that don’t have them. Isn't inheritance to create hierarchy enough? why?
by tester756 5y ago
>ADTs are the obvious choice but somehow in 2021 most people are using languages that don’t have them.
Isn't inheritance to create hierarchy enough? why?
Node
SubNode1 SubNode2
SubNode1.1 SubNode2.1
- wyager 5y agoUsing inheritance in this way is a hack to emulate some of the functionality of ADTs. Grammars are perhaps one of the most poignant examples where the various constructors in your type might have no behaviors in common, so adherence to a shared interface is nothing but a vague indication that these types are somehow related. Sealed classes let you recover a little bit more of the functionality.
- tester756 5y agowell, but from security standpoint it should be fine?