A Fresh Look at Comparisons, Take 2

Janice Caron caron800 at googlemail.com
Fri Apr 18 06:11:12 PDT 2008


On 18/04/2008, Henning Hasemann <hhasemann at web.de> wrote:
>  - You can still not build partially ordered classes at all? (Ie
>   something similar to complex numbers) Is there a rationale for this?

Only that Paul said it wasn't necessary, and, on reflection, his logic
is reasonable.

Basically, I think the reasoning is... what's the point? After all, if
c and d are complex numbers, then

    if (c < d)

could easily be rewritten as

    if (c.im == 0 && d.im == 0 && c.re < d.re)



>  - You can still have opCmp say two objects are equal and opEqual say
>   they're not? (or vice versa, respectively)

Sure. You can also define opAdd() to do subtraction. Sometimes, you
just have to rely on common sense.

(Also, there are rare circumstances where you might want to do that
deliberately, so that, for example, an AA can contain duplicate
"equal" keys).

Anyway, I don't really see why we would consider that a problem.



More information about the Digitalmars-d mailing list