D arithmetic problem
Daniel Keep
daniel.keep.lists at gmail.com
Wed Jun 3 06:12:16 PDT 2009
bearophile wrote:
> 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
*Every* integral type is signed by default. Why should byte be an
exception?
If it's really that much of a concern, deprecate byte and add sbyte.
More information about the Digitalmars-d
mailing list