4 ms·
Well, C++ has the same restriction and a lot of people's distaste of overloaded operators comes from that language. User-defined operators and overloaded operat
by pcwalton 12y ago
Well, C++ has the same restriction and a lot of people's distaste of overloaded operators comes from that language. User-defined operators and overloaded operators are separate features, in fact—OCaml has the former but not the latter.
My personal preference is to allow operator overloading, but to (a) enforce that overloaded operators must have reasonable type signatures (via concepts or similar); (b) restrict overloadable operators to mathematical operators (e.g. not the comma operator), and (c) set a good precedent in the standard libraries and community against using mathematical operators for non-mathematical operations (e.g. don't overload bitshift operators for I/O in the standard libraries).