Why don’t we see C-like languages that allow for callables with polymorphism in the return type? I could see how the additional type inference would be a hurdle, but we have plenty of languages with full-fledged type inference systems (that work for varying levels of ‘work’).
Edit: By return type polymorphism I mean overloading the function signature only in the return type. For example, C++ and Java only allow overloading in the type of the formal parameters, not in the return type.
If by ‘return type polymorphism’ you mean overloading based on the return value type, I’m not sure about other languages, but for C++ here’s the answer (pretty much from the horse’s mouth):
Function return types don’t come into play in overload resolution simply because Stroustrup (I assume with input from other C++ architects) wanted overload resolution to be ‘context independent’. See 7.4.1 – ‘Overloading and Return Type’ from the ‘C++ Programming Language, Third Edition’.
They wanted it to be based only on how the overload was called – not how the result was used (if it was used at all). Indeed, many functions are called without using the result or the result would be used as part of a larger expression. One factor that I’m sure came into play when they decided this was that if the return type was part of the resolution there would be many calls to overloaded functions that would need to be resolved with complex rules or would have to have the compiler throw an error that the call was ambiguous.
And, Lord knows, C++ overload resolution is complex enough as it stands…