https://issues.dlang.org/show_bug.cgi?id=13114

Steven Schveighoffer <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected],
                   |                            |[email protected]

--- Comment #1 from Steven Schveighoffer <[email protected]> ---
Further update, I think there is a valid case for allowing redefining of opCmp
and not opEquals -- if you are not changing the equality portion of opCmp.

For instance:

class C
{
    this(int x, int y) pure {this.x = x; this.y = y;}
    int x;
    int y;
    override bool opEquals(Object other) { if(auto o = cast(C)other) {return x
== o.x;} return false;}
    override int opCmp(Object other) { if(auto o = cast(C)other) {return x <
o.x ? -1 : x > o.x ? 1 : 0;} return -1;}
    override hash_t toHash() const { return x; }
    override string toString() const { return "{" ~ x.to!string ~ ", " ~
y.to!string ~ "}";}
}

class ReverseC : C
{
    override int opCmp(Object other) { if(auto o = cast(C)other) {return x >
o.x ? -1 : x < o.x ? 1 : 0;} return -1;}
}

ReverseC should be able to be an AA key, because the opCmp calculation for
equality did not change. This can be an AA key under 2.065, and under the new
compiler/druntime.

I think we cannot actually fix this issue. I don't know what to do here. CC'ing
major players on this issue to make sure it gets noticed.

--

Reply via email to