3 ms·
At least you have the chance to implement your own std::partial_ordering if necessary; in most languages those kind of features would be built into the compiler
by logicchains 2y ago
At least you have the chance to implement your own std::partial_ordering if necessary; in most languages those kind of features would be built into the compiler.
- eru 2y agoHaskell solves this nicely: your own operators just shadow the built-in operators. (And you can opt to not import the built-in operators, and only use your own. Just like you can opt not to import printf in C.)
- dataangel 2y agothat's not the issue, the problem is the operator is required by the language to return a type from the stdlib, so you have to pull in the stdlib to get that type
- eru 2y agoIn Haskell, when you define your own operators (including those that have the same name as those already defined in the standard library), you can specify your own types. There's basically no operators defined 'by the language' in Haskell, they are all defined in the standard library. (Of course, the standard library behaves as-if it defines eg (+) on integers in terms of some intrinsic introduced by the compiler.)