tech-misc archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Endian-specific types
On Thu, Sep 08, 2016 at 01:45:07PM -0400, Mouse wrote:
> >> ive toyed with the idea of making types like this: [...endianness...]
>
> Much of the problem with endian-specific types is that - at least in C,
> and I think in C++ - types describe values, and endianness is not a
> property of a value; it's a property of a value as serialized into an
> octet (or other unit smaller than the value) stream. It does not make
> sense to talk about the endianness of a value in a CPU register, any
> more than it makes sense to talk about the bit-endianness of a byte in
> memory (unless the machine supports bit addressing or otherwise imposes
> some ordering on the bits within a byte).
But it does make sense to talk about the byte-endianness of a word in
memory, and then hey what do you know, it's a property of a variable.
Types describe variables as well as values, and furthermore types are
more than just sets of legal values. (Otherwise all structures
containing say two ints would be the same type.)
--
David A. Holland
dholland%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index