Re: !foo vs foo == nil
Re: !foo vs foo == nil
- Subject: Re: !foo vs foo == nil
- From: Todd Blanchard <email@hidden>
- Date: Fri, 22 Aug 2008 20:59:25 -0700
Wow, I'm simply blown away at the level of confusion.
I've been doing C for a long long time. Prior to C99 there was no
boolean type in C. I have never missed it.
I have never ever seen a bug introduced by doing code like
if(foo)
or
if(!foo)
I have seen a large number of bugs introduced by programmers trying to
"make" a boolean type for C and a lot of bugs introduced by trying to
test for explicit trueness or nullness with code like
if(foo == true)
or
if(foo = NULL)
and so forth. I have also spent a lot of time devising clever macros
to work around conflicting boolean types in other people's libraries.
All of the right things happen if you simply accept that zero in all
of its forms is false and not zero is true. All of the trouble comes
when trying to define what is true or trying to write a comparison
expression when simply testing the value of the variable would do.
Put me firmly in the
if(foo)
camp.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden