News for hackers. Stuff that matters.
Re:If Inheritance is so bad, why does everyone use it? by Capricorn2481 on Friday April 12, 2024 @08:45PM (#40019255)
> you have a function that takes a general type, and you can pass multiple specific types and it will do the right thing

What does this have to do with inheritance? This is just a generic function.

> And if you want to avoid huge if-else statements, you should put the code for the special cases in the classes, not in each function that operates on them

This doesn't sound any different from how people usually talk about inheritance.

I am not convinced it gives you anything more than composition does. Composition is very easy to setup and easy to change. And there are certainly functional ways to do runtime polymorphism.

Re:If Inheritance is so bad, why does everyone use it? by SpaghettiCthulu on Sunday April 14, 2024 @10:08PM (#40036425)
> > you have a function that takes a general type, and you can pass multiple specific types and it will do the right thing > > What does this have to do with inheritance? This is just a generic function.

It's a generic function with compile-time compatibility checks.