Can #define `token-string' be empty?

John Chambers jc at mit-athena.UUCP
Wed Feb 27 02:29:18 AEST 1985


> C source:				Output from preprocessor:
> ===================================	=======================================
> #include <stdio.h>			...  (stuff from the include file here)
> #define	X
> main()					main()
> {					{
> 	printf("This is X: %d\n",X);		printf("This is X: %d\n",);
> }					}
> Clearly, X was not considered to be 1 (or anything), and when I attempted to
> used the test #if X == 1, the preprocessor complained of syntax error (since
> it translated the line into  #if  == 1 .

This is a good example of something I wish language implementors would learn
to get right.  X was considered to be something.   X is exactly what the
definition says:  a null string; an empty string; a string of length 0.

About 1500 years ago, there was a great advance in European mathematics when 
they learned from the Arabs about the number zero.  Previous to this, zero
was not considered to be a number, because it "didn't represent anything".
What some Arab genius realized is that, actually, zero is a number which
"represents nothing".  There is a very important distinction here.  Without
a symbol for nothing, you can't even have a balanced budget!

Character strings can be null.  To say that X is a null string is not 
to say that X doesn't represent anything; it is to say that X represents 
nothing.  These phrases are not equivalent; the first leads to confusions 
like people on the net are having, as well as to compilers that make 
funny irregular special cases out of "missing" tokens; the second leads 
to the useful understanding that a symbol may usefully appear in text 
without representing anything in the end result.  Without this ability,
we can't even have comments!

One of the real pains in using lots of software is that so many programmers
haven't caught on to this 1500-year-old idea that it is useful to have a
symbol that represents nothing.  As a result, we have all these library
routines that fail when an argument is zero; we have compilers that do
funny things when symbols are missing; etc.  How can we go about teaching
all the worlds' programmers about this very useful concept?

			John Chambers



More information about the Comp.lang.c mailing list