Seven Original Sins of K&R (Long)

Bob Goudreau goudreau at dg-rtp.dg.com
Thu Sep 27 02:39:27 AEST 1990


In article <12780 at sdcc6.ucsd.edu>, mautner at odin.ucsd.edu (Craig Mautner)
writes:
> 
> The Second Original Sin was the failure to make "NULL" 
> a keyword.  Beginning C programmers wonder why you have 
> to "#include <stdio.h>" in a program that doesn't use 
> standard I/O.  Some compilers don't even object when 
> you assign an integer constant to a pointer without a 
> typecast, especially when the constant happens to be 
> zero.  Don't blame the compiler.  The poor thing can't 
> tell the difference between a zero integer constant and 
> "NULL".

Or better yet, how about a new operator named "nil", which takes
a type name (sorry, pointer types only need apply) and which evaluates
to the nil pointer of that type?  For example,

	char *	cp;

	....

	if (cp == nil(char *)) ....


Of course, it's easy enough to implement now as a macro, but think
of all the comp.lang.c articles that could have been avoided by
building it into the language and thus avoiding having the token
"0" do double duty...

----------------------------------------------------------------------
Bob Goudreau				+1 919 248 6231
Data General Corporation
62 Alexander Drive			goudreau at dg-rtp.dg.com
Research Triangle Park, NC  27709	...!mcnc!rti!xyzzy!goudreau
USA



More information about the Comp.lang.c mailing list