Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!mcnc!rti!xyzzy!throopw From: throopw@xyzzy.UUCP (Wayne A. Throop) Newsgroups: comp.lang.c Subject: Re: A modest proposal Message-ID: <162@xyzzy.UUCP> Date: Tue, 28-Jul-87 17:15:54 EDT Article-I.D.: xyzzy.162 Posted: Tue Jul 28 17:15:54 1987 Date-Received: Thu, 30-Jul-87 04:28:27 EDT References: <1362@cullvax.UUCP> <6125@brl-smoke.ARPA> Organization: Data General, RTP NC. Lines: 49 > gwyn@brl-smoke.ARPA (Doug Gwyn ) >> drw@cullvax.UUCP (Dale Worley) >>What I propose is the NULL be made into a keyword of the language >>which acts like a constant and whose value is a pointer, and >>eliminating "0" as the null pointer. As far as I know, no decently >>written C program will break on this, and it would clean a lot of >>cruft out of the language definition. If by "decently written C program", you mean to exclude such things as { extern void f(); f( NULL ); } (that is, passing this new keyword as a parameter to a function with no prototype in scope), then I agree, but wonder where the benefit is? Clearly, having a typeless NULL keyword will not help portability much, since pointers of different types are potentially different sizes. I guess it boils down to the facts that 1) no decently written program will break on the use of 0 as a pointer constant now. 2) I don't know of a case that is unsafe or nonportable with the use of 0 that would be made safe and portable by the use of a typeless pointer constant. > Although I agree with the intent, if 0 were not still guaranteed > to be equivalent to the null pointer, LOTS of existing applications > (for example, almost all of UNIX) would break. Perhaps the best > approach would be to introduce NULL as a keyword, "deprecate" 0 for > null pointer (using other words, however), and hope that a future > revision of the C standard could remove the deprecated feature. > Unfortunately I suspect that you won't be able to persuade X3J11 > that this is worth doing, but feel free to try. Well, I agree that 0 must remain. But I still don't see what the NULL keyword buys you. Or perhaps the light dawns: it would issue an error diagnostic if used as a parameter with no prototype in scope, right? There might be some small benefit to that, I suppose, but only for newly minted code. But for newly minted code, I'd druther kill more birds with fewer stones by having an option to have the compiler issue a diagnostic whenever there is no prototype in scope. So I'm not enthusiastic about NULL as a keyword. -- "You have 15 seconds to comply." --- out-of-control robot, from RoboCop -- Wayne Throop !mcnc!rti!xyzzy!throopw