3 ms·
So, do you want to have addIntegers, addUnsignedLongs, addFloats, etc. too? You would need to have those or separate operators in some strongly typed languages
by Someone 6y ago
So, do you want to have addIntegers, addUnsignedLongs, addFloats, etc. too?
You would need to have those or separate operators in some strongly typed languages that do not automatically coerce ints to floats, etc.
Also, for floats, a+b == b+a, but you don’t necessarily have a+b+c == c+b+a. So, if you’re strict in that “should not alter the result regardless of the types”, you would have to forbid using + on floats in some more complex expressions.
Finally, I don’t see how “operator overloading […] encourages programmers to shove disparate functionalities (often with different axioms) into the same operator.” is much different from “function overloading […] encourages programmers to shove disparate functionalities (often with different axioms) into the same function”.