Path: utzoo!attcan!utgpu!watmath!att!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcsun!ukc!mucs!ian From: ian@ux.cs.man.ac.uk (Ian Cottam) Newsgroups: comp.lang.c Subject: Abandon NULL for (0) Message-ID: <6502@ux.cs.man.ac.uk> Date: 20 Sep 89 09:21:12 GMT Organization: Computer Science, University of Manchester, UK Lines: 45 Here is a C style suggestion that I am about to adopt (for you to throw bricks at). It is related to the issue of silly-little-macros, but I have decided to use it after following discussions on the net regarding implementations and users (!) that (re-)define NULL to something stupid. The original motivation for writing NULL rather than 0 was, IMHO, to help the reader of a program text spot where the denotation 0 meant ``the null pointer''. I propose that the integral constant expression (0) be used instead of NULL. Some example code: /* * Initialise a new stack variable; return false iff init attempt fails */ bool initstack(Stack *s) { extern void *malloc(unsigned int); StackHeaderPtr tmp= (StackHeaderPtr)malloc(sizeof(StackHeader)); if ( (0) == tmp ) return false; /* malloc failed -- no store */ else { tmp->top= (0); /* set stack empty */ tmp->reserve= (StackElemPtr)malloc(sizeof(StackElem)); if ( (0) == tmp->reserve ) return false; /* malloc failure */ else { *s= (Stack)tmp; return true; } } } ----------------------------------------------------------------- Ian Cottam, Room IT101, Department of Computer Science, University of Manchester, Oxford Road, Manchester, M13 9PL, U.K. Tel: (+44) 61-275 6157 FAX: (+44) 61-275-6280 ARPA: ian%cs.man.ac.uk@nss.cs.ucl.ac.uk JANET: ian@uk.ac.man.cs UUCP: ..!mcvax!ukc!mur7!ian -----------------------------------------------------------------