ANSI C suggestions

Henry Spencer henry at utzoo.UUCP
Tue Oct 16 02:54:28 AEST 1984


> (1)	Get rid of that requirement that all floating point arithmetic
> 	be done in floating point.  ...

I assume you mean "be done in double precision"!  The ANSI committee is
ahead of you on this one.  Expressions involving only "float" quantities
may be done in "float" precision if the compiler so chooses.  Note that
this is not compulsory; it's up to the compiler implementors.  Note also
that constants are still "double" unless explicitly cast to "float", which
is a nuisance (the alternative was nightmarish problems in deciding the
type of a floating-point constant).  Not ideal, but workable.

> (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.  ...

Again the committee is ahead of you.  There is a "const" modifier in the
draft, taken from recent Bell-internal versions of C.  It does more than
you suggest -- in my opinion, more than is really necessary -- but it can
be used to get this effect in particular.  It is not just a convenience;
people who are putting tables into ROM for micros need it badly.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,linus,decvax}!utzoo!henry



More information about the Comp.lang.c mailing list