▲ | m-schuetz 5 days ago | |
Operator overloarding is essential for computer graphics libraries for vector and matrix multiplication, which becomes an illegible mess without. | ||
▲ | lifthrasiir 5 days ago | parent [-] | |
I personally think that operator overloading itself is justified, but the pervasive scope of operator overloading is bad. To me the best solution is from OCaml: all operators are regular functions (`a + b` is `(+) a b`) and default bindings can't be changed but you can import them locally, like `let (+) = my_add in ...`. OCaml also comes with a great convenience syntax where `MyOps.(a + b * c)` is `MyOps.(+) a (MyOps.(*) b c)` (assuming that MyOps defines both `(+)` and `(*)`), which scopes operator overloading in a clear and still convenient way. |