On Wed, 28 Sep 2016 10:06:43 +0000, pineapple wrote:
> I think the cleanest possible solution would be to allow comparison
> operators to be overridden with opBinary and opBinaryRight, as well, but
> use opCmp and opEquals instead if they exist. I can't think of any way
> this would break existing code.

What happens with this?

  struct MyInt {
    int value;
    MyInt opBinary(string op)(MyInt other) {
      return MyInt(mixin("value " ~ op ~ " other.value"));
    }
  }

Obvious pattern for wrapping a value. Comparisons used to be unsupported, 
producing an appropriate error message:

  Error: need member function opCmp() for struct MyInt to compare

Now they produce a different, opaque error message, which will have to be 
created, but the current equivalent is:

  Error: recursive opCmp expansion

That's not a breakage, but it is an unfortunate direction for the quality 
of error messages.

Reply via email to