[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Problem with +numberWithBool: ?
From: |
Alexander Malmberg |
Subject: |
Re: Problem with +numberWithBool: ? |
Date: |
Fri, 30 Jan 2004 16:14:02 +0100 |
Richard Frith-Macdonald wrote:
> On 30 Jan 2004, at 11:26, Helge Hess wrote:
> > On Jan 29, 2004, at 2:12 PM, Richard Frith-Macdonald wrote:
> >> Booleans in objc can be YES or NO ... this is not the same thing as
> >> true/false in C/ObjC conditionals where 0 is false and anything
> >> non-zero is true.
> >
> > Such an assumption (which is probably not backed by the ObjC "spec")
>
> I have noticed that when you say 'probably' you seem to mean 'I haven't
> checked' :-)
>
> Page 178 of the NeXTstep reference, section headed Defined Types ...
>
> 'BOOL A boolean value, either YES or NO'
But this isn't a spec, and it tells. That statement is way too vague to
be useful when implementing things. Anyway, the intent here is
irrelevant. objc/objc.h has:
typedef unsigned char BOOL;
and, in practice, that's what matters.
> I'm sure I've seen arguments about this before
Do you have a link to this prior discussion (if it was public)?
> - I judged the
> consensus to be that the
> BOOL type is intended to be boolean, and the fact that it's stored as a
> char is an
> implementation detail.
It isn't an implementation detail since it means that BOOL isn't a true
boolean type. Compare this with c99's _Bool, which is a true boolean
type:
#include <objc/Object.h>
int main(int argc,char **argv)
{
int i=5;
BOOL objc_bool;
_Bool c99_bool;
objc_bool=i;
c99_bool=i;
printf("objc_bool=%i c99_bool=%i\n",objc_bool,c99_bool);
return 0;
}
This will print:
objc_bool=5 c99_bool=1
- Alexander Malmberg
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), (continued)
- Re: [RFA]: BOOL coding standards (Was: Problem with+numberWithBool: ?), Alexander Malmberg, 2004/01/31
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Kazunobu Kuriyama, 2004/01/30
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Richard Frith-Macdonald, 2004/01/30
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Richard Frith-Macdonald, 2004/01/30
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Adam Fedor, 2004/01/30
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Sheldon Gill, 2004/01/31
- Re[2]: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Manuel Guesdon, 2004/01/31
- Re: [RFA]: BOOL coding standards (Was: Problem with+numberWithBool: ?), Alexander Malmberg, 2004/01/31
- Re: Problem with +numberWithBool: ?,
Alexander Malmberg <=
- Re: Problem with +numberWithBool: ?, Nicola Pero, 2004/01/30
- Re: Problem with +numberWithBool: ?, Alexander Malmberg, 2004/01/30
- Re: Problem with +numberWithBool: ?, Philippe C.D. Robert, 2004/01/30
- Re: Problem with +numberWithBool: ?, Pascal J . Bourguignon, 2004/01/30
- Re: Problem with +numberWithBool: ?, Richard Frith-Macdonald, 2004/01/30
- Re: Problem with +numberWithBool: ?, Pascal J . Bourguignon, 2004/01/30
- Re[2]: Problem with +numberWithBool: ?, Manuel Guesdon, 2004/01/30