why implicitly allowing compare ubyte and byte sucks

Rainer Deyke rainerd at eldwood.com
Fri Jun 12 14:45:01 PDT 2009


Don wrote:
> That's true. What you are doing is removing the int/byte inconsistency,
> by making  uint == int comparisons behave the same way that ubyte ==
> byte comparisons do now.
> Notice that your proposal
> (1) preserves the existing behaviour of byte==ubyte (which the original
> poster was complaing about);

Yes.

> (2) silently changes the behaviour of existing D and C code (that
> involves int==uint); and

True.  I don't consider C compatibility a major issue, but others do.
(If C compatibility was a major issue for me, I'd never even consider
moving from C++ to D.)

> (3) assumes that the code as written is what the programmer intended. I
> suspect that this type of code is frequently an indicator of a bug.

Yes, but the opposite behavior is just as likely to be a bug.  Between
two behaviors that mask possible bugs, I'd rather have the
mathematically correct behavior.  The alternative is to flat-out ban
comparison of mixed-sign types.


-- 
Rainer Deyke - rainerd at eldwood.com



More information about the Digitalmars-d mailing list