Re: BOOL value in Dictionary
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