3 ms·
Addition and concatenation have different properties: concatenation is not commutative. So the problem is not the types, strings vs int, but different operation
by plesn 16y ago
Addition and concatenation have different properties: concatenation is not commutative. So the problem is not the types, strings vs int, but different operations. In a language that puts an emphasis on principles like haskell, I find "++" a elegent syntax for concatenation, but otherwise I find that Python's approach of using "+" and throwing a type error is good enough.
- Zak 16y agoI see the overloading of operators to do fundamentally different sorts of operations as a mistake in all cases. That's not to imply that (in a language with infix syntax) operator overloading is bad, but that it should be used to add the same kind of operation to a new situation. Overloading + to work with a fixed-point math library makes sense. Overloading + to do concatenation does not.