gnustep-dev
[Top][All Lists]
Advanced

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

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


From: Pascal J . Bourguignon
Subject: Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?)
Date: Sun, 8 Feb 2004 02:37:14 +0100

David Ayers writes:
> You can't rely on the C truth value (i.e. rely on the "true" value or 
> 256) to be passed through the method invocation which converts the 
> integer to unsgnied char in this case '0' and expect to have get the 
> 'YES' BOOL value as the parameter in the implementation of +numberWithBool.
> 
> 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

?


For a time I had this '.signature' file. Perhaps I should have kept it
longer:

void PleaseWrite(bool isBetter,void* pointer,int value)
{if((!isBetter)&&(pointer!=NULL)||(value==0)){ print("Right!\n");}}
void DontBeSilly(bool isSilly,void* pointer,int value)
{if((isSilly!=true)&&(pointer)||(!value)){ print("Wrong!!\n"); }}


-- 
__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]