4 ms·
I think we get into fuzzy territory when we use one term to refer to a complex feature, without having good terms for constituent parts of that feature. If java
by abeppu 6y ago
I think we get into fuzzy territory when we use one term to refer to a complex feature, without having good terms for constituent parts of that feature. If java offered the ability to call methods in infix position, and give methods non-alphanumeric names, and maybe express something about precedence order, that would support a good share of uses for operator overloading without actually overloading anything. `x :+: y` would be easy enough to read as "an addition-like operation which is not the inbuilt addition" and would still closely resemble the math, and might be fine in a context where x and y are complex numbers or whatever. It would come at the obvious cost of requiring changes to a bunch of the supportive tooling surrounding the language.
I think the messy part added by overloading specifically is that if `Complex`, `RealVector`, `List` etc all override addition, then there's some common class or interface which provides the declaration which they all override, and same for subtraction, multiplication, etc, and soon you have a large pile of interacting abstract definitions, which some language users will find daunting.
- capitalsigma 6y agoSounds like re-inventing Haskell.
- abeppu 6y agoOr maybe this is just scala. I guess the issue is, is it possible to add "operator overloading" and get something sensible without adding a whole pile of other definitions?
- zokier 6y agoThat sounds still like overloading unless you'd require the infix function names to be globally unique. And if you require global uniqueness then that gets pretty nasty pretty quickly with libraries that might use same names.