• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: !foo vs foo == nil
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >!foo vs foo == nil (From: Torsten Curdt <email@hidden>)
 >Re: !foo vs foo == nil (From: Torsten Curdt <email@hidden>)
 >Re: !foo vs foo == nil (From: "John C. Randolph" <email@hidden>)
 >Re: !foo vs foo == nil (From: "Michael Ash" <email@hidden>)
 >Re: !foo vs foo == nil (From: Thomas Engelmeier <email@hidden>)
 >Re: !foo vs foo == nil (From: Negm-Awad Amin <email@hidden>)
 >Re: !foo vs foo == nil (From: Thomas Engelmeier <email@hidden>)
 >Re: !foo vs foo == nil (From: Negm-Awad Amin <email@hidden>)
 >Re: !foo vs foo == nil (From: "Michael Ash" <email@hidden>)
 >Re: !foo vs foo == nil (From: Negm-Awad Amin <email@hidden>)
 >Re: !foo vs foo == nil (From: "Michael Ash" <email@hidden>)

  • Prev by Date: Incorrect instance of custom view loading after unarchiving
  • Next by Date: Re: Incorrect instance of custom view loading after unarchiving
  • Previous by thread: Re: !foo vs foo == nil
  • Next by thread: Re: !foo vs foo == nil
  • Index(es):
    • Date
    • Thread