gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?)


From: Pascal J . Bourguignon
Subject: Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?)
Date: Tue, 3 Feb 2004 06:09:35 +0100

Helge Hess writes:
> On 02.02.2004, at 20:47, Nicola Pero wrote:
> >> 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;
> >
> > Wouldn't this have been a waste a space just to just store a YES/NO ?
> 
> Well, isn't that you who is suggesting that a "true boolean" is worth 
> major restrictions? ;-)
> 
> Your point is pretty mood because:
> a) BOOL is *NOT* specified to be char and indeed is not mapped to char 
> on
>     some platforms
> b) even char is as wasteful requiring 8 times the memory necessary
>     (which is why everyone is using bitfields anyway) - apparently it is
>     worth that
> 
> Is int more wasteful than that:
> @interface MyFunkyObject
> {
>    BOOL a;
>    BOOL b;
> }
> I guess not, because a and b are probably aligned to 32 bits 
> boundaries. Is
> - (void)doIt:(BOOL)_a
> more wasteful than int? I also guess not, because the register _a is 
> being passed in is available in any case and probably not going to be 
> shared by multiple char variables.
> 
> In short: the practical gain of using char for BOOL is minimal, 
> especially in comparison to the already wasteful use of char instead of 
> a bit.
> 
> Greets,
>    Helge
> 
> PS: this discussion is a lot of fun - and I indeed learned a lot I 
> didn't knew before ;-)
> -- 
> http://docs.opengroupware.org/Members/helge/
> OpenGroupware.org
> 
> 
> 
> _______________________________________________
> Gnustep-dev mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/gnustep-dev

-- 
__Pascal_Bourguignon__                     http://www.informatimago.com/
There is no worse tyranny than to force a man to pay for what he doesn't
want merely because you think it would be good for him.--Robert Heinlein
http://www.theadvocates.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]