Re:If Inheritance is so bad, why does everyone use it?
by VirusNewbie on Thursday April 11, 2024 @04:38PM
(#40006565)
>You can’t build a dynamic list of objects implementing the same interface in different ways with parametric polymorphism.
Yes you can. that's the whole point of type classes.
Re:If Inheritance is so bad, why does everyone use it?
by layer8 on Thursday April 11, 2024 @04:54PM
(#40006712)
Not without runtime polymorphism. Parametric polymorphism does not imply nor by itself implement runtime polymorphism. I.e. C++ templates, or generics in other languages, provide parametric polymorphism, but not runtime polymorphism.
Re:If Inheritance is so bad, why does everyone use it?
by gpderetta on Friday April 12, 2024 @04:11AM
(#40010410)
Universal Vs existential qualification.
For example in c++ std::function exhibits parametric polymorphism without templates.
Re:If Inheritance is so bad, why does everyone use it?
by Kranar on Thursday April 11, 2024 @05:08PM
(#40006824)
Type classes are not parametric polymorphism.
Re:If Inheritance is so bad, why does everyone use it?
by VirusNewbie on Friday April 12, 2024 @12:56PM
(#40015071)
So you think a List[Function[Unit]] all does the same thing?
As another example, the Unix file interface (open(), read(), write(), flush(), close()) etc. is an example of runtime polymorphism, where the file descriptors identify objects with different implementations (depending on whether it’s a regular file, a directory, a pipe, a symbolic link, a device, and so on).
All operating systems and many libraries tend to follow this pattern: You can create objects to which you receive a handle, and then you perform various operations on the objects by passing the respective handle to the respective operation, and under the hood different objects will map to different implementations of the operation.