Path: utzoo!utgpu!water!watmath!clyde!ima!johnl
From: rsalz@bbn.com (Rich Salz)
Newsgroups: comp.compilers
Subject: Re: static declarations & accessibility
Summary: That's what CONST is for
Message-ID: <792@ima.ISC.COM>
Date: 15 Dec 87 19:21:15 GMT
References: <785@ima.ISC.COM>
Sender: johnl@ima.ISC.COM
Reply-To: rsalz@bbn.com (Rich Salz)
Organization: BBN Laboratories, Cambridge MA
Lines: 31
Approved: compilers@ima.UUCP

In comp.compilers (<785@ima.ISC.COM>), ihnp4!wucs1!wuibc2!brown (Michael Brown) writes:
>All C language implementations I've use have allowed the address of
>the static data to be obtained if one wanted to do weird things...
>I'd argue that this should be prohibited by the semantics of the
>static declaration.

Not a good argument:  it's overruled by the semantics of pointers, and
you've just outlawed the following construct:
	doit()
	{
	    static int done;

	    if (!done) {
		done = 1;
		...
	    }
	    ...
	}

Anyhow, the ANSI X3J11 C standardization committee invented (okay, stole
from C++) the "const" keyword for just that sort of thing.  It's similar
to the VMS C "readonly" storage-class.  Check out a copy of the draft
for more info.
-- 
For comp.sources.unix stuff, mail to sources@uunet.uu.net.
[Similar comments received from several other readers.  -John]
--
Send compilers articles to ima!compilers or, in a pinch, to Levine@YALE.EDU
Plausible paths are { ihnp4 | decvax | cbosgd | harvard | yale | bbn}!ima
Please send responses to the originator of the message -- I cannot forward
mail accidentally sent back to compilers.  Meta-mail to ima!compilers-request