[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?)
From: |
Helge Hess |
Subject: |
Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?) |
Date: |
Mon, 2 Feb 2004 19:58:33 +0100 |
On 02.02.2004, at 15:17, Richard Frith-Macdonald wrote:
Until someone (you?) found a reference in apple documentation warning
that boolValue might return a non-YES/NO value from an NSNumber, I'd
have said that yes, we are entitled to insist on correct usage of
BOOL.
We are not talking about return values! I think we pretty much agree
that a -(BOOL)boolValue *should* return YES or NO (I wouldn't go as far
and claim that it must).
Cocoa reference says:
"+ (NSNumber *)numberWithBool:(BOOL)value
Creates and returns an NSNumber containing value, treating it as a BOOL"
Which doesn't help. But to end this ridiculous discussion I tried on
Panther:
NSLog(@"Hello, World!: %@", [NSNumber numberWithBool:5]);
gives
2004-02-02 19:52:35.633 BoolTest[4187] Hello, World!: true
So, topic closed (if only for compatibility reasons) unless someone
digs out some document explicitly stating that the input to NSNumber
+numberWithBool: is required to be an exact YES or NO. (in that case we
should file a bug report at Apple, ... ROTFL ;-)
I would again like to point out that if the intention was to limit BOOL
to YES and NO, it would have been defined as
typedef enum { YES, NO } BOOL;
But it wasn't defined that way to be compatible with C boolean
expressions. The existence of YES and NO is a simple convenience so
that people don't clutter when assigning constant values to a variable.
Helge
--
http://docs.opengroupware.org/Members/helge
OpenGroupware.org
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Richard Frith-Macdonald, 2004/02/01
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), David Ayers, 2004/02/02
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Richard Frith-Macdonald, 2004/02/02
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Richard Frith-Macdonald, 2004/02/02
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?),
Helge Hess <=
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Nicola Pero, 2004/02/02
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Pascal J . Bourguignon, 2004/02/02
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Helge Hess, 2004/02/02
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Pascal J . Bourguignon, 2004/02/03
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Pascal J . Bourguignon, 2004/02/03
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Richard Frith-Macdonald, 2004/02/02
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Helge Hess, 2004/02/02
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Pascal J . Bourguignon, 2004/02/02