3 ms·
Why? It seems natural and I can't think of a case where it could be confusing off the top of my head (for strongly typed languages).
by happytoexplain 2y ago
Why? It seems natural and I can't think of a case where it could be confusing off the top of my head (for strongly typed languages).
- WalterBright 2y agoAlgol was infamous for: "10" + 1 does that mean 11 or "101" ?
- fragmede 2y agowat https://www.destroyallsoftware.com/talks/wat https://www.destroyallsoftware.com/talks/wat
- happytoexplain 2y agoThat shouldn't compile (or it should be an IDE error in interpreted languages). That doesn't seem to be the fault of operator overloading.
- mhh__ 2y ago+ should be commutative.
- happytoexplain 2y agoI disagree - I think the intuition that mathematical addition being commutative means that the + operator must be commutative is not pragmatic. Whether + must be commutative is less relevant than whether + must be mathematical. I.e. I see no problem - theoretically, practically, or semantically - with using + to combine things in programming, mathematically or otherwise. As long as it's in a strong language that doesn't support nonsense. E.g. JavaScript might not deserve operator overloading (I imagine - I rarely use JS).