<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 26 July 2014 13:33, Manu <span dir="ltr"><<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 26 July 2014 06:38, Walter Bright via Digitalmars-d <span dir="ltr"><<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div>On 7/25/2014 4:10 AM, Regan Heath wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Sure, Andrei makes a valid point .. for a minority of cases.  The majority case<br>
will be that opEquals and opCmp==0 will agree.  In those minority cases where<br>
they are intended to disagree the user will have intentionally defined both, to<br>
be different.  I cannot think of any case where a user will intend for these to<br>
be different, then not define both to ensure it.<br>
</blockquote>
<br></div>
You've agreed with my point, then, that autogenerating opEquals as memberwise equality (not opCmp==0) if one is not supplied will be correct unless the user code is already broken.<br>
</blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">No, because there's no obvious reason to define opEquals if you do define opCmp, and the opEq</div></div>
</blockquote></div><br></div><div class="gmail_extra">Oops, sorry! Hit the send hotkey >_<<br><br>No, because there's no obvious reason to define opEquals if you do define opCmp and the opEquals would be the same.<br>
</div><div class="gmail_extra">It seems to me, at face value, that opCmp is for full range of comparisons, and opEquals is for unordered types. Surely this is a reasonable conclusion to make?</div><div class="gmail_extra">
<br></div><div class="gmail_extra">I don't see how you can say that a compiler generated opEquals in the presence of a user opCmp can reliably be correct.</div><div class="gmail_extra">It may be correct, if you're lucky, and that's the best offer you'll get.</div>
<div class="gmail_extra">opCmp==0 however is practically certain to be correct, since <= and >= are required to work... and the api embodies the concept of equality, it would be very hard to write an implementation where equal was broken, but <,<=,>=,> all worked.</div>
</div>