[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?)
From: |
Nicola Pero |
Subject: |
Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?) |
Date: |
Sun, 8 Feb 2004 02:40:41 +0000 (GMT) |
> > IOW: C "truths" (i.e. C truth semantice) aren't implicitly converted to
> > BOOL YES/NO. The conversion must be made explict.
>
> But who in his sane mind would write:
>
> > >> [NSNumber numberWithBool: (i=256)]; => NO
>
> instead of:
>
> [NSNumber numberWithBool: (i=256)!=0]; => YES
>
> ?
It's easy to build more convincing examples.
If you follow the "BOOLs are the same as C truth values" philosophy
without thinking too much, then you could end up writing stuff like
- (BOOL) isNonEmpty
{
return count;
}
where count is an int counting the number of items in an array.
You could think that since BOOLs work as C truth values, if count is > 0,
this is YES, if it's 0, it's NO (I'm sure you've seen enough C coders to
know they love being "clever" in that way with C truth values), so the
code should work, but unfortunately it doesn't.
- RE: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), Adam Fedor, 2004/02/05
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), Richard Frith-Macdonald, 2004/02/07
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), David Ayers, 2004/02/07
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), Kazunobu Kuriyama, 2004/02/07
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), David Ayers, 2004/02/07
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), Pascal J . Bourguignon, 2004/02/07
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?),
Nicola Pero <=
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), Kazunobu Kuriyama, 2004/02/09
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), Pascal J . Bourguignon, 2004/02/09
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), David Ayers, 2004/02/09
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), Richard Frith-Macdonald, 2004/02/09
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), Pascal J . Bourguignon, 2004/02/09
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), David Ayers, 2004/02/09
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), Kazunobu Kuriyama, 2004/02/09
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), Pascal J . Bourguignon, 2004/02/09
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), Kazunobu Kuriyama, 2004/02/10
- Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?), David Ayers, 2004/02/10