[net.lang.c] Adding new keywords

guido@mcvax.uucp (Guido van Rossum) (10/07/86)

In article <86900064@haddock> karl@haddock writes:
>Adding a new keyword will not obsolete any programs except those that use it
>as an identifier.  Such programs are easy to upgrade ("#define dead id_dead"
>is almost sufficient, if you're lazy).  Conversely, programs written for the
>new language can be downgraded for old compilers with "#define dead void" --
>no such simple fix is available if "goto" acquires new semantics.

Sorry, Karl, it's not that easy.  The "#define dead id_dead" trick may
fail horribly if the keyword is used in the standard include files
provided by the implementation.

For example, take ANSI C: exit and abort are declared in <stdlib.c> (*).
If this file is included in my program, which also makes use of a
variable called 'dead', and an implementation chooses to declare exit
and abort as 'dead', I have to find out pretty exactly where 'dead' is
used as what before I know where to add "#define dead id_dead": before
line 1 of my file will cause a syntax error in <stdlib.h>, after all
include files may be too late (if my own include files also reference my
variable 'dead'); I may end up having to reshuffle the #include
directives or even use the editor to change of all occurrences of 'dead'
in my sources to 'id_dead' (probably also changing some output strings
in the process!).

This is not an imaginary problem: I've been fighting it in the Apple MPW
C compiler, which has new keywords 'extended' and 'comp' and uses them
extensively in <math.h>.  I interpret my ANSI draft (*) as *forbidding*
the addition of new reserved words to a strictly conforming
implementation; I hope that's still there in the "final" draft.

-- 
	Guido van Rossum, CWI, Amsterdam <guido@mcvax.uucp>

(*) This refers to the May, 1986 draft of the ANSI C standard.