2 ms·
I'm not sure OO fundamentally requires the kind of inheritance relationship that is familiar from languages like C++, Java and C#, though. For example, the Lis
by Chris_Newton 16y ago
I'm not sure OO fundamentally requires the kind of inheritance relationship that is familiar from languages like C++, Java and C#, though.
For example, the Liskov Substitution Principle is phrased in terms of a subtype relationship between two types. This is a logical relationship rather than a physical one: it is about whether both types present the same interface in terms of (some aspect of) their state and behaviour, and therefore generalised code can be written that interacts analogously with instances of either type.
This subtype relationship need not be realised via a subclass relationship, which is a physical relationship related to the mechanics of inheritance hierarchies and so on.
I don't see any problem with mixing pattern matching and OO, if you allow a representation as an algebraic data type as one view of a class and provide a mechanism to convert between them in some suitable way. Indeed, I'm fairly sure I've seen papers investigating this approach, though I'm afraid I can't immediately remember what the authors called it so I could look them up; if anyone knows what I'm talking about, please post citations if you have them.
- silentbicycle 16y agoLate reply to a late reply. While I think you're probably right, if I'm already representing things with algebraic data types, I'd rather just skip using OO altogether.