Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mimsy!umd5!brl-adm!adm!DRIEHUIS%HLERUL5.BITNET@wiscvm.wisc.EDU From: DRIEHUIS%HLERUL5.BITNET@wiscvm.wisc.EDU Newsgroups: comp.lang.c Subject: Re: Writing readable code Message-ID: <8168@brl-adm.ARPA> Date: Mon, 6-Jul-87 00:27:58 EDT Article-I.D.: brl-adm.8168 Posted: Mon Jul 6 00:27:58 1987 Date-Received: Mon, 6-Jul-87 06:46:52 EDT Sender: news@brl-adm.ARPA Lines: 29 First: the subject of NULL being defined as 0 has been explored rather thoroughly over the time I read comp.lang.c, and as far as I'm concerned an implementation of C with NULL being defined as something other than 0 is plainly wrong. Second: the open() call is defined as returning a file descriptor, which is explicitly defined as a small, positive integer. Therefore, checking against minus one is equivalent to checking against being negative. As for the readability, I dislike both non-zero constants (as in 'fd == -1') and symbolic constants (as in 'fd == ERROR'), if the definition of (in this case) a file descriptor specifically says that only *positive* values are valid (it says so on page 159 in K&R for the truly devout). Of course, you should keep in mind that fopen() returns EOF, which is defined as -1, and that assuming that any negative return from fopen() means an error has occurred, is non-portable as far as machines with possibly valid negative pointers are concerned (This is the case on small-model 808x for instance). - Bert Bert Driehuis, LICOR Leiden, The NetherlandsV.N.G. The Hague P.S. While proofreading this letter, I noticed I had written something to the extent that zero equals minus one (I thought: 'x == -1', I wrote down: 'checking against zero'). Now, I remember someone being flamed for implying that if(!p) is equivalent to if(p!=NULL), and retaliating that this provides conclusive proof that C isn't readable. Well, I just proved conclusively that English isn't writable (at least to me) - Bert.