> Also, unlike Java, where such problems are [...] usually handled with a runtime cast through the Object ground type, languages with HM type inference usually require there to actually be a valid type-conversion function between the mis-matched types in question.
And they usually also have pattern-matching, which makes this relatively straightforward (when there is in fact a valid conversion).
It's worth taking a look at the OO system in OCaml, by the way. It works very similarly to duck-typing, but it also infers the required methods at compile time: "this function requires its first argument to be any object that takes this message with these argument type(s) and returns that type." This decouples polymorphism from inheritance/subclassing. That way, you can use OO without getting too bogged down in yucky "Circle/Ellipse" problems ( http://c2.com/cgi/wiki?CircleAndEllipseProblem ).
Ironically, the OO system in OCaml doesn't seem to get used all that much, though - with the other abilities the language already gives you, you don't really need to use OO except for problems for which it is actually a good fit, and in practice that's fewer than many people would claim.
And they usually also have pattern-matching, which makes this relatively straightforward (when there is in fact a valid conversion).
It's worth taking a look at the OO system in OCaml, by the way. It works very similarly to duck-typing, but it also infers the required methods at compile time: "this function requires its first argument to be any object that takes this message with these argument type(s) and returns that type." This decouples polymorphism from inheritance/subclassing. That way, you can use OO without getting too bogged down in yucky "Circle/Ellipse" problems ( http://c2.com/cgi/wiki?CircleAndEllipseProblem ).
Ironically, the OO system in OCaml doesn't seem to get used all that much, though - with the other abilities the language already gives you, you don't really need to use OO except for problems for which it is actually a good fit, and in practice that's fewer than many people would claim.