|
From: | Leigh Smith |
Subject: | Re: Re[2]: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?) |
Date: | Mon, 2 Feb 2004 00:01:12 -0500 |
Hm, well, actually I do prefer "if (ptr == NULL)" over "if (!ptr)". Not sure why.
Implicit is the assumption that NULL is always 0, which isn't actually a specification, merely a convention of the compiler that NULL is actually something like:
#define NULL (void *) 0While unusual for a compiler to declare NULL to be something other than 0, it would be legal C, depending on the processor architecture. I'd definitely favour the more explicit ptr == NULL since you are then articulating that you are checking against a NULL pointer, rather than doing an implicit cast to an integer before then inverting the implicit comparison against 0.
-- Leigh Smith mailto:address@hidden http://www.leighsmith.com
[Prev in Thread] | Current Thread | [Next in Thread] |