3 ms·
I think overloading + so that a + b != b + a is problematic. I know this is the case for strings and lists, but those cases are very well established.
by petters 8y ago
I think overloading + so that a + b != b + a is problematic.
I know this is the case for strings and lists, but those cases are very well established.
- johncolanduoni 8y agoI would think that adding two dictionaries will make people think of the established cases for other collections, rather than the less related case of numbers.
- quietbritishjim 8y agoThat is already the case for + on sequences though (e.g. string and list). In my experience it never causes confusion in practice in those circumstances.
- sametmax 8y agoAnd a = 1 is not equality. Welcome to the world of programming, where we don't all try to match mathematical conventions because many of us suck at maths and are practical.
- gizmo385 8y agoThere is not rule of math stating that + must always be commutative. It is commutative for real numbers, yes, but there are plenty of use cases mentioned elsewhere in this discussion where + is not commutative.
- albntomat0 8y agoIt intuitively makes sense for lists and strings, as those have an order that matters. I agree with you (and disagree with other commenters) that this particular case is more problematic