4 ms·
>For me the main point is (runtime) polymorphism. But you don't actually care about runtime polymorphism here. You care about polymorphic behavior, which can
by VirusNewbie 3y ago
>For me the main point is (runtime) polymorphism.
But you don't actually care about runtime polymorphism here. You care about polymorphic behavior, which can be implemented in a much more composable way with parametric polymorphism.
- layer8 3y agoYou can’t build a dynamic list of objects implementing the same interface in different ways with parametric polymorphism. 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.
- VirusNewbie 3y ago>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.
- layer8 3y agoNot 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.
- gpderetta 3y agoUniversal Vs existential qualification. For example in c++ std::function exhibits parametric polymorphism without templates.
- Kranar 3y agoType classes are not parametric polymorphism.
- VirusNewbie 3y agoSo you think a List[Function[Unit]] all does the same thing?