A tuff question about strings - (nf)

johnl at ima.UUCP johnl at ima.UUCP
Wed Aug 17 08:36:15 AEST 1983


#R:sdcsvax:-364800:ima:15900010:000:760
ima!johnl    Aug 16 12:18:00 1983

The question is asked whether a C compiler that makes strings read-only
is in conformance with K&R..

It appears that it is indeed wrong.  The C reference in section 2.5 states
that strings are semantically static arrays of characters.  The discussion
of "static" in section 4 talks about variables, not constants.  You might
read the exact words a little differently, but the intention is pretty clear.

In practice, zillions of existing C programs expect to be able to write on
their strings, so that read-only strings will break programs regardless of
the moral status of the compiler.

John Levine, ima!johnl

PS:  There has been some discussion of a "readonly" keyword to mark data
that should be read-only, but I never heard of it being blessed at Bell.



More information about the Comp.lang.c mailing list