From: Richard R. <sf...@ol...> - 2003-10-27 21:07:18
|
On Mon, Oct 27, 2003 at 01:56:24PM -0600, Stephen J Baker wrote: > Richard Rauch wrote: > > >>(2) I agree. I also would like to take out the "!= NULL". > > > >I'll add that to my mental list of things to cull as I go, then. > > It's a matter of taste - but I tend to go though putting those INTO > the code while I'm tidying it up! I think that if the code had read: return_if_fail( ptr1 || ptr2 ); ...rather than: return_if_fail( ptr1 != NULL || ptr2 != NULL ); ...the slip of reasoning would not have occurred. > Without the !=NULL thing, a pointer tends to look like a boolean (which > it isn't). C doesn't have a real boolean. You have to imagine a boolean, which can be done as well with a pointer as with an int or char, etc. Though even with C++, I prefer this approach. Maybe my old roots as a long-standing C programmer are showing. I find it cleaner and clearer, since there is a distinguished "invalid" pointer and it acts like a "false" value, and the compiler "automatically" does this check for you. I think of it as overloading the if() expression (or overloading the truth-testing of an expression) in a natural manner. -- "I probably don't know what I'm talking about." http://www.olib.org/~rkr/ |