Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!gatech!seismo!rochester!pt.cs.cmu.edu!ius2.cs.cmu.edu!edw From: edw@ius2.cs.cmu.edu.UUCP Newsgroups: comp.lang.c Subject: Re: NULL pointers as arguments Message-ID: <1134@ius2.cs.cmu.edu> Date: Thu, 30-Apr-87 12:37:02 EDT Article-I.D.: ius2.1134 Posted: Thu Apr 30 12:37:02 1987 Date-Received: Fri, 1-May-87 04:35:28 EDT References: <1130@ius2.cs.cmu.edu> <148@nbisos.NBI.COM> Distribution: na Organization: Carnegie-Mellon University, CS/RI Lines: 63 In article <148@nbisos.NBI.COM>, zog@nbisos.NBI.COM (Chris Herzog) writes: > > The fact that floats are passed as doubles is supported by the fact that > the compiler knows enough to coerce back when the called function picks > up the parameter. It's still your responsibility to pass the correct types. > > The main thrust here with pointers is that different types of pointers > can have COMPLETELY different representations. Coercion to a common type > is not desireable. > > All of these problems would go away if people would cast NULL to the > proper value. > > "What about existing code which assumes .... ?" > > Tough ! It's wrong ! > > We don't need to change the language definition to support junior programmers. > If you can't use a simple tool like lint, then step aside and let someone > who really cares do the task. I'm so sick of all of the exceptions being > made to support and promote mediocrity ! > > Chris Herzog FLAME ON Is it always your nature to try intimidating people?? I ask for comments not insults *ssh*l*. FLAME OFF The only example given to me of where pointer sizes differ amoung types is on word-address machines. Character and byte arrays are spaced optimized by packing many bytes per word. The problem is how to address individual bytes. One word pointers just won't cut it. An extra byte is needed to address a given byte within the word (actually I would imagine a whole word is used for the offset because of alignment problems). Anyway, two words should be able to represent any pointer type on a word-address machine, right? Also the type coercion of lets say (float *) to (char *) could be defined as: the float pointer value with offset 0 (I'm assuming that all floats are aligned on word boundries). NULL could be defined as ((char *) 0) or ((void *) 0). With reguards to your comments about floating point args, the C compiler knows to type coerce doubles back to singles only because you have declared the input parameter to be of type float. The same situation would holds for pointers types. The compiler would know what to type coerce the "generic" pointer parameter to by what it is declare to be in the function parameter list. "Word" is being synonymously with the unit that represents the size of a pointer to a "word" in this article. -- Eddie Wyatt