News for hackers. Stuff that matters.
Re:If Inheritance is so bad, why does everyone use it? by tombert on Thursday April 11, 2024 @04:51PM (#40006686)
I feel like Clojure-style multimethods accomplish this better than inheritance. I can simply write a dispatcher that dispatches the correct function based on some kind of input.

This is evaluated at runtime, thus giving me the runtime polymorphism, but doesn't make me muck with any kind of taxonomy trees. I can also add my own methods that work with the dispatcher, without having to modify the original code. I don't feel like it's any less convenient than inheritance, and it can be a lot more flexible. That said, I suspect it performs worse, so pick your poison.

There are no comments on this comment yet.