Reserved identifiers, was Re: Thoughts on moving towards ANSI

Jerry Leichter leichter at cs.yale.edu
Tue Feb 14 03:14:14 AEST 1989


In article <3669 at geaclib.UUCP>, daveb at geaclib.UUCP (David Collier-Brown) writes...
 
> 
>  At some point the compiler-writers are going to have to start
>thinking about known (often partial) solutions to the namespace
>pollution problems of simple languages like C. (and PL/1, lest
>anyone think I'm being snarky with the use of "simple").
>  Several of these are
> ...
>	4) controlled vocabulary
>		a) the following 5280 words are reserved...
> ...

PL/I has its share of problems, but one it has NEVER had is namespace pollu-
tion.  There are NO reserved words in PL/I!  Even such bizarre constructs as:

	IF IF = THEN THEN ELSE = ELSE ELSE THEN = IF

are perfectly legal.

Having no reserved words was an explicit goal of the original designers.  They
knew that they were designing a large language, which was supposed to address
a very broad spectrum of programmers.  They also had experience with COBOL,
which has perhaps the longest list of reserved words of any extant language.
(Well, if you count in all the "reserved" things in the library, ANSI C in a
hosted environment is now a strong competitor!)  They considered it unreason-
able to require a programmer to know all the reserved words, even those used
for features of the language he had no interest in and knew nothing about.

Doing without reserved words requires some extra care in designing the grammer
of your language, but it can be done.  (Years ago, I remember seeing an arti-
cle somewhere, probably in SIGPLAN Notices, showing how to translate any
grammar WITH reserved words into one WITHOUT, or point out where the ambigui-
ties arise.  I've never been able to find it, though.)  That most people are
not aware of this feature of PL/I is testimony to the fact that it is possible
for the resulting grammar to be quite natural.

							-- Jerry



More information about the Comp.std.c mailing list