4 ms·
Operator-overloading has seemed like a weird debate to me ever since I realized operators are only different from functions because: 1) They are infix (often i
by brundolf 6y ago
Operator-overloading has seemed like a weird debate to me ever since I realized operators are only different from functions because:
1) They are infix (often in languages where functions cannot be)
2) They can use one of a handful of special characters in their name
3) In languages with methods - which you could argue are called infix - they lack the extra ceremony of .()
These are all pretty much syntax concerns, and it seems like they could be solved at a fairly superficial level. I don't see much reason why operators need special treatment under the hood.
Edit: Now that I think about it, they're also polymorphic in some languages that lack polymorphic functions. But that's somewhat of an edge-case if you count methods.