jacob navia said:
There is one point where you are right is in the lack
of boolean arrays.
If I declare
bool tab[8];
it would be sensible to expect that those eight bits would be
stored in 1 byte (if byte is 8 bits).
It would also be sensible to expect that each of those 8 objects would
occupy at least one byte, just like any other non-bit-field object.
But yes, it might be nice to have a syntax for bit arrays in C.
Ordinary array notation, though, already has a well-defined meaning
that's incompatible with bit arrays.
It is always stated that then
bool *p = &tab[3];
would have no meaning but it would be easy to say that for boolean
pointers, they either
1) Point to the byte where the bit is stored and not to the bit itself.
2) Have some different structure with two pointers: one for the byte and
another for the bit.
Option (2) would be really difficult to implement, having two kinds of
pointers would make things very difficult everywhere.
Yes, but there are real-world C implementations that already have two
or more kinds of pointers, sometimes of different sizes. Implementing
pointers to single bits would be no more difficult than, say, byte
pointers on a Cray vector system.
Option (1) would be simple: pointers do not work with those arrays,
and only array notation would be allowed.
You're suggesting that the elements of the array would be treated like
bit fields. In that case, &tab[3] should be illegal. Making it the
address of the byte containing tab[3], rather than of tab[3] itself,
doesn't make any sense.