Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83 SMI; site sun.uucp
Path: utzoo!watmath!clyde!floyd!harpo!decvax!decwrl!sun!gnu
From: gnu@sun.uucp (John Gilmore)
Newsgroups: net.lang.c
Subject: Re: Can ANSI Standard C be "Optimized"
Message-ID: <636@sun.uucp>
Date: Mon, 19-Mar-84 13:38:16 EST
Article-I.D.: sun.636
Posted: Mon Mar 19 13:38:16 1984
Date-Received: Tue, 20-Mar-84 01:41:12 EST
References: <6061@decwrl.UUCP>, <404@decvax.UUCP> <139@homxa.UUCP>
Organization: Sun Microsystems, Inc.
Lines: 30

Rather than add the "volatile" attribute to variable declarations, the C
standards committee has taken a safer alternative:  Assume that everything
is volatile, but permit it to be declared "const".  An object declared
"const" cannot be modified.  Furthermore, the "const" attribute can appear
at each level of indirection; eg

	const char *pcc;

declares a (modifiable) pointer, which is guaranteed by the programmer
to point to non-modifiable storage (a const char).  If you say

	char *const pcc = "string";

then it can (for example) put the string in the text segment.  A declaration
like

	char *const cpc;

declares a pointer, cp, which is not modifiable; but the object it points
to (a char) can be modified.

This can be used by the compiler -- there's no need to worry about aliasing
of const things.  For example, if a compiler already has the value of cpc in
a register due to a previous calculation, it need not reload it.  This can
be valuable for function parameters -- mostly they are constant throughout
the function.

The draft standard goes into more detail.  If you don't know anyone who has
one (or is on the committee), call CBEMA at 202-737-8888; they should be
able to point you right.  (Don't ask me.)