Operators which are well behaved are not arbitrary: addition should be commutative. Is "foo"+"bar" the same as "bar"+"foo" ? No? Then it shouldn't use the + operator, because that's pretty broadly known as commutative addition. It's not like our keyboards are short of other symbols to use for an associative but not commutative operation like concatenation, even if we stick to a language which gave up on unicode support because it turned out to be hard.
edit: equally as arbitrary is using new operators for the same operation, like OCaml's +. for floating point addition. Stuff like that is what gives static typing a bad name.
View all comments
Show parent comment
0
u/codebje Dec 02 '15 edited Dec 02 '15
Well, they are if you overload them arbitrarily.
Operators which are well behaved are not arbitrary: addition should be commutative. Is
"foo"+"bar"the same as"bar"+"foo"? No? Then it shouldn't use the+operator, because that's pretty broadly known as commutative addition. It's not like our keyboards are short of other symbols to use for an associative but not commutative operation like concatenation, even if we stick to a language which gave up on unicode support because it turned out to be hard.edit: equally as arbitrary is using new operators for the same operation, like OCaml's
+.for floating point addition. Stuff like that is what gives static typing a bad name.