tech-misc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Endian-specific types



>> 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.  [...]
> 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.

True as far as it goes.  But what you really want there is a type with
type-specific methods for loading and storing.  That is, you need a
language that has a distinction - or at least has the ability to create
a distinction - between values qua values and values-as-stored.

C is not such a language; it does not have any distinction between
types describing values and types describing variables, ie, stored
values.  While I don't really know C++, my impression is that it is
like C in this respect.

That's why I think trying to do endian-specific types in C - possibly
excepting as a compiler extension - is a mistake.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index