D arithmetic problem

bearophile bearophileHUGS at lycos.com
Wed Jun 3 04:54:25 PDT 2009


Don:
> Yes. Yet there's an issue here -- EVERYONE expects 'byte' to be 
> unsigned. Walter even forgot it when he did the first release of htod.
> The uses for signed bytes are so rare, that any use of 'byte' is highly 
> likely to be an error.

>>[...]
> I agree, it's bug-prone.

I agree a lot.
I too have put one or two bugs in my D programs caused by not remembering (even if I know it) that byte is signed in D. Signed byte is not intuitive at all.

Even if it looks a bit dirty, I think that doing the following 3 things some bugs from D2 code can be avoided:
- make byte unsigned.
- add sbyte, signed byte.
- deprecate ubyte from the language.

This doesn't give problems in porting C code to D.

Bye,
bearophile



More information about the Digitalmars-d mailing list