|
|
|
|
|
by pcwalton
3596 days ago
|
|
> Don't get me wrong, I love me some parametric polymorphism, but it's by no means a simple thing as far as I've seen. I disagree. You should look at OCaml (and Standard ML, though the eqtypes in SML are a botch): generics are dead simple there. Much simpler than Go interfaces, in fact. Sure, there's always "one more thing" you could add, but that's always true for anything in any language. Slippery slope is a fallacy for this reason. > or else you force people to use dynamic checks/allocations/casts that reduce your type-safety and bog the code down relative to the "optimal" design Which is what happens even more if you don't have generics! |
|
Standard ML's `eqtypes` aren't a bad idea at all:
(0) They ensure that `op=` can only be used on things that actually have decidable equality.
(1) If SML were to be equipped with dependent types in the future, it would make sense to only allow `eqtypes` as type indices. First-order unification can be used on syntactic values of `eqtypes`, so the basic architecture of a Damas-Milner type checker can be retained, in spite of having dependent types.
OTOH, equality and comparisons in OCaml are completely broken.