[comp.lang.c] A modest

rbbb@rice.EDU (David Chase) (04/28/87)

Chris Torek explained the use of "volatile" and "const" to me; for
example, a pointer to a device register might be declared

      volatile unsigned int * const csr = 0172150;

meaning that the value of the pointer never changes, but the value in the
pointed-to location could be read or written at any time.  Given this
sudden flash that "const" and "volatile" are just like "*", "[]" and "()"
as far as declaration syntax goes, I was struck by the contrast between
the nice, short, words to indicate pointer-ness, function-ness, etc and
the terribly long words to indicate volatile-ness, etc.

In the spirit of the language (with the kind assistance of Chris Torek, I
hope he doesn't mind too much) I propose that we use "?" to indicate
"volatile" and "=" to indicate "const".  "Unsigned" is another of those
long ones; that should be "+".  Given this small overloading of the
operators, the above declaration becomes

      +int ?*=csr=0172150;

Of course, we don't need the "int", so it really becomes

      +?*=csr=0172150;

It is also possible to solve the "how big is an char/short/int/long"
controversy that occasionally pops up; obviously, we just use the number
of bits as a declaration.  Thus

      +?32*=csr=0172150;

Of course, 32 is redundant on a VAX.

David