[Issue 13179] AA key type TagIndex now requires equality rather than comparison

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jul 23 23:44:10 PDT 2014


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

--- Comment #18 from Jacob Carlborg <doob at me.com> ---
(In reply to Jonathan M Davis from comment #15)

> Agreed. I don't think that I said otherwise. What I was trying to point out
> that is if you define opEquals, then if you use the type with an AA, then
> you're going to need to define toHash as well. So, forcing the user to
> define opEquals simply because they defined opCmp potentially forces them to
> define toHash. And if the compiler-generate opEquals and toHash would have
> been consistent with opCmp, then having to define them just increases the
> risk that you're going to screw up defining them (particular toHash). What
> it would mean would be that any type that you wanted to use as an AA key
> that defined opCmp (as was previously required) would then have to define
> opEquals and toHash as well even if it shouldn't be necessary.

That's how the current behavior in 2.066.0-b5 is. If opCmp is defined and the
type is used as an AA key the compiler will force you to defined opEquals as
well. And if opEquals is defined the compiler will require you to define toHash
as well. I'm guessing this is to ease the transition from opCmp being used for
AA keys to opEquals.

--


More information about the Digitalmars-d-bugs mailing list