ANSI C suggestions

Guy Harris guy at rlgvax.UUCP
Mon Oct 15 09:05:06 AEST 1984


> As long as we are discussing improvements to the language, I would
> like to suggest a couple:
> 
> (1)	Get rid of that requirement that all floating point arithmetic
> 	be done in floating point. ... I don't care if I have to
> 	set a compiler flag or whatever, as long as I can use single
> 	precision arithmetic.

I presume you meant "done in double precision", not "done in floating
point"; floating point is not required to be in double precision
by the ANSI C draft standard.  (It's not even so required by the PDP-11
hardware, but that's another story.)

> (2)	The DEC C compiler allows a "readonly" designation on global
> 	variables.  This is handy to insure that one does not overwrite
> 	static lookup tables and such.  VAX type machines can easily
> 	implement readonly variables.  I suggest that readonly should
> 	be part of the language in much the same way as register 
> 	variables -- i.e. the compiler does not have to implement things
> 	that way if it is in a bad mood or the machine does not
> 	support it.

Most all machines implementing UNIX can implement readonly variables -
if you can have shared text, you can probably have shared readonly data.
(To do it on machines with separate I&D space with programs that use
separate I&D space would require changes to UNIX, but there do exist
UNIX versions with those changes.)  This is also in the draft standard,
although they chose "const" instead of "readonly", possibly to make it
compatible with the syntax used in Bell Labs' C++ language.  "const" is
actually fancier than, say "static", in that you can have a "pointer to
const XXX" as well as a "const pointer to XXX"; presumably, this is so the
compiler can detect code that tries to modify "const" variables (an oxymoron?)
at compile time.  I suspect it works as you suggest - i.e., an implementation
can ignore it if it chooses.

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy



More information about the Comp.lang.c mailing list