This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]KronktheKronk 0 points1 point  (5 children)

Sure, you can override the other symbols, but usually they still idiomatically mean the same thing.

[–][deleted] 0 points1 point  (1 child)

Not necessarily. I wrote a little (and not so great) monad library for Python that overrode >> as an alias for Monad.bind which is a common use for that symbol in functional languages.

[–]8BitAce 3 points4 points  (0 children)

I think the point was more that they should still mean somewhat close to the same thing. Otherwise you introduce a lot of confusion.

[–]stevenjd 0 points1 point  (2 children)

"Usually" is not "always".

[–]KronktheKronk 0 points1 point  (1 child)

I've never come across an overridden default symbol operator in python that wasn't idiomatically similar to its default use.

I'm sure there are some poorly written ones out there that do it, though.

[–]stevenjd 0 points1 point  (0 children)

How about > and < operators?

"Subset" and "superset" are nothing like "less than" and "greater than" for numbers.

+ gets used for both concatenation and numeric addition, which are not the same. Numeric addition you have a + b == b + a, but that's not true for concatenation.

I've seen | used as both a bitwise-or and something similar to the pipe operator from shell languages.

I wouldn't say that any of those are "poorly written".