|
|
|
|
|
by eru
1823 days ago
|
|
Operator overloading in the style of C++ is pretty silly, and your concerns apply. Have a look at how eg Haskell deals with operators: - You can define your own, so you don't need to re-use bit-shifting for IO. And in fact, you wouldn't be able to do so. - There's also specific kind of overloading, so that '+' can work with different types. But eg you couldn't turn bit-shifting '<<' into an IO operator. The rules for shadowing of operators are the same as the rules for shadowing any other function or variable name. In fact, operators are just a weird syntax to write binary functions in Haskell. Otherwise they behave exactly the same. Whether to use operators or functions with 'normal' names is then only a stylistic question, and a library can offer both styles to its users. (And you can retrofit the style of an existing library without having to have access to the library.) |
|