digitalmars.D.bugs - [Issue 17573] New: Make opCmp more flexible
- via Digitalmars-d-bugs (24/24) Jun 29 2017 https://issues.dlang.org/show_bug.cgi?id=17573
https://issues.dlang.org/show_bug.cgi?id=17573 Issue ID: 17573 Summary: Make opCmp more flexible Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: halager gmail.com The way custom comparisons are currently implemented force you to always return an integer and doesn't tell you what operation you are doing. An example of how it can bite is that mir can't do elementwise comparisons similar to how it does addition or multiplication since it has to return an int for comparisons. So a + a == [2, 2, 2] and a * a == [1, 1, 1] but you can't express a < a == [false, false, false]. I get the logic of only making the user create a single comparison function but maybe a possible fix would be to check if there is an opBinary for the relevant comparison operator before doing the usual opCmp logic. --
Jun 29 2017