Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!columbia!rutgers!clyde!ima!haddock!karl
From: karl@haddock.UUCP (Karl Heuer)
Newsgroups: comp.lang.c
Subject: Re: Reserved words in C
Message-ID: <291@haddock.UUCP>
Date: Wed, 24-Dec-86 16:40:17 EST
Article-I.D.: haddock.291
Posted: Wed Dec 24 16:40:17 1986
Date-Received: Wed, 24-Dec-86 21:49:14 EST
References: <1524@hoptoad.uucp> <1016@zeus.UUCP>
Reply-To: karl@haddock.ISC.COM.UUCP (Karl Heuer)
Organization: Interactive Systems, Boston
Lines: 32
Summary: C already has hundreds of "reserved" words

In article <1016@zeus.UUCP> dant@tekla.tek.com (Dan Tilque) writes:
>I'm fairly new to using C but one of the things I liked about it was the
>small number of reserved words in the language. ... Is this going to change?
>Is C going to become like COBOL?  I certainly hope not.

Even in pre-ANSI C, the problem exists:

[a]  A naive user includes  to declare a FILE.  He doesn't know
     anything about "NULL", and tries to use that name as a local variable:
	register int NULL;	/* NUmber of Long Lines */
     This fails because NULL is a macro defined in that header file.  Hence
     its name must be considered "reserved", even though it's not known to the
     compiler proper.

[b]  A user who has read all the ANSI documents tries to write the following
     (legal) program:
	void write(s) char *s; { printf("%s\n", s); }
	main() { write("Hello, world\n"); return 0; }
     This will fail under most current implementations, because there is a
     library routine call write() which, although not mentioned by the user,
     is nevertheless invoked indirectly through printf().  Thus, every name in
     the standard library must be considered reserved, whether used or not.
     (Note that for this particular example, "write" is *not* part of the ANSI
     standard, so a strictly conforming implementation must not have printf()
     call write().  It may, however, have printf() call _write(), and provide
     a function named write() which also calls _write().)

This is a tough problem in general, and I don't know what the answer is.  (One
approach is the VMS-like notion of having a prefix on everything reserved:
"sys$write()", "mth$cos()", etc.  Ugly, but perhaps necessary.)

Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint