[Issue 17573] New: Make opCmp more flexible
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Thu Jun 29 12:24:53 PDT 2017
    
    
  
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 at puremagic.com
          Reporter: halager at 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.
--
    
    
More information about the Digitalmars-d-bugs
mailing list