A fresh look at comparisons

Janice Caron caron800 at googlemail.com
Mon Apr 14 11:51:06 PDT 2008


On 14/04/2008, Janice Caron <caron800 at googlemail.com> wrote:
>  In general, if a is of type A, and b is of type B, where A != B, and
>  there exists a common type C into which both A and B will implicitly
>  cast, then we only need to concern ourselves with (cast(C)a ==
>  cast(C)b).

On second thoughts...

If B and C both derive from A, and we try to compare

    B b;
    C c;
    if (b == c) ...

Should we be testing for

    if (cast(A)b == cast(A)c) ...

or should we be returning false? That's a tricky question, and I
confess I don't know the answer.

I guess I'll think about it for a while... :-)



More information about the Digitalmars-d mailing list