www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14593] New: operator overloading can't be used with


          Issue ID: 14593
           Summary: operator overloading can't be used with expression
           Product: D
           Version: unspecified
          Hardware: Other
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

A motivating example is using expression templates to specify db queries.

db.get!Person.where!(p => p.age > 21 && p.name == "Peter")

This has the following problems:
- opCmp doesn't allow to capture the op
- it's not possible to overload &&
- opEquals must return a bool (but here it needs to return p)

A solution would be to use the generic opBinary for < <= > >= == iff
opCmp/opEquals don't exist and also extending it to && ||.

May 16 2015