by WalterBright · 1mo ago · 0 comments
(D sez `char` is unsigned. No more nonsense!)
C also needs to implement proper arrays. D does it, and that one feature is worth its weight in gold:
https://www.digitalmars.com/articles/C-biggest-mistake.html
It's sooo nice to not have array overflows anymore.
i'm old school. ascii is 7 bits, if you're using the 8th bit you probably want a sign since you've left the realm of ascii chars
Not that I disagree with making basic types unsigned by default, just not in C.
char - unsigned 8 bits
byte - signed 8 bits
ubyte - unsigned 8 bits
char is used for utf-8, byte and ubyte are signed and unsigned small integers. This seems like small thing, but it makes D code much more readable than C.I bet a lot of existing C code will break if one sets char to signed with a compiler switch.
Anybody reviewing C code and sees just char will have to waste time wondering if the code handles the implementation-defined signed-ness correctly.
And yes, I know about stdint.h, a poor attempt to deal with this problem.