• 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: BOOL value in Dictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BOOL value in Dictionary


  • Subject: Re: BOOL value in Dictionary
  • From: Ed Wynne <email@hidden>
  • Date: Fri, 21 Nov 2008 11:20:07 -0500


On Nov 21, 2008, at 10:54 AM, David Blanton wrote:

Why is :

if ( boolVar == YES) or if ( boolVar == NO)

bad form?

if (boolVar == YES) is bad form, but if (boolVar == NO) and if (boolVar != NO) is not.


In C the concept of false has one and only one value, 0, which is #defined to be NO / false, etc. The concept of true, on the other hand, is defined as its complement. Any non-0 value. The YES check misses most of the not-false space.

A lot of people will argue about the relative merits of BOOL vs bool vs a true boolean type and how they can only have two possible meanings, but that is all superceded by the fact that we are discussing a C type language. You don't always know where your values are coming from, whether they respect the types you've somewhat arbitrarily chosen to label them, and as such, there are no guarantees as to their validity. You should check the C assumptions as to their truthiness, not arbitrary and unenforced type assumptions.

-Ed

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: 
 >Re: BOOL value in Dictionary (From: Heinrich Giesen <email@hidden>)
 >Re: BOOL value in Dictionary (From: David Blanton <email@hidden>)

  • Prev by Date: Re: Autorelease Question
  • Next by Date: Re: Cocoa "canvas" view ?
  • Previous by thread: Re: BOOL value in Dictionary
  • Next by thread: Re: BOOL value in Dictionary
  • Index(es):
    • Date
    • Thread