32 ms·
> Polymorphism moves the burden of reasoning about types from compile time to run time, How? Doesn't this depend on the specific kind of polymorphism/implement
by Dewie 12y ago
> Polymorphism moves the burden of reasoning about types from compile time to run time,
How? Doesn't this depend on the specific kind of polymorphism/implementation of which, rather than being about polymorphism inherently? What if types are erased at compile-time and the compiler generates functions and such for all the relevant types that you need?
> but in practice understanding much of the polymorphic code ive worked on still requires a mental process of "OK, if it's THIS type then this happens; if its THAT type then something else happens."
I think this is impossible with parametric polymorphism - if you say that the input data can be any type, you can't make any assumptions about what type it might be. If the incoming type only has the constraint that it can be tested for equality on other values of the same type, they only function you can use on it is ==, and so on.