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: Nicola Pero
Subject: Re: [RFA]: BOOL coding standards (Was: Problemwith+numberWithBool:?)
Date: Tue, 10 Feb 2004 13:36:35 +0000 (GMT)

> If you're unsure about what your c code really means, it's certainly a
> good idea to be careful about generating BOOL values, and to use only
> YES and NO. I don't even see anyone arguing that this shouldn't be in
> the coding standard for GNUstep (something like "Code that produces BOOL
> values must produce only the values YES (1) and NO (0).").

I agree with Alexander here, and I would even go as far as saying that
isYes() shouldn't be mentioned in the coding standards.

isYes() should be compatible with the coding standards, but not compulsory
(in other words, I don't like isYes(), but I'm fine if other people like
it).

Of course, I also agree that when isYes() is used, it should be possible
to set a flag to have it work as isYes(X) --> ((X) != NO).

=

At the moment, the two main recommendations we get from this discussion 
are -

 * avoid comparing BOOLs to YES directly (to avoid traps with code using
non-0 for YES)

 * prefer code explicitly returning/assigning YES and NO (to avoid traps
with implicit conversions from non-0 to YES)

I believe we all agree on those.  So let's just write those in the coding
standards. :-)





reply via email to

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