--- Comment #8 from bearophile_h...@eml.cc 2012-10-23 09:32:37 PDT ---
(In reply to comment #7)
> I think byte should be unsigned by default. So I am for sbyte(signed byte - Is
> there really anyone who need it?) and byte (unsigned byte)
Ideally I agree with you. In practice D built-in types are prefixed by "u" when
unsigned, so a more practical solution is the C# one, that is using the "ubyte"
and "sbyte" names pair.
Regarding the usefulness of signed bytes: small data types like ubyte, sbyte,
short, ushort and even float are mostly useful in aggregates, like arrays and
arrays of structs. They are not so useful if you need only one of them.
Recently I have used an array of sbyte values to represent indexes in a short
array (statically known to be shorter than 127 items). Using 1 byte instad of
an int/uint/size_t saves space if you have many of such indexes. And saving
space means reducing cache misses. And to represent those indexes I used a
sbyte instead of a ubyte because I have used -1 to represent "missing value").
sbyte values are not used often, but it's right to have them too in a system
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------