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: Alexander Malmberg
Subject: Re: [RFA]: BOOL coding standards (Was: Problem with+numberWithBool:?)
Date: Mon, 02 Feb 2004 23:01:35 +0100

Kazunobu Kuriyama wrote:
> Alexander Malmberg wrote:
> > +When using BOOL values, care should be taken to ensure to ensure that all
> > +non-zero values are treated as true.
> > +
> > +Methods that return BOOL values should return only YES or NO to avoid
> > +triggering problems in code that treats only YES as true.
> 
> In the first paragraph, we see 'to ensure' twice...

Oops. Will fix.

> In the last paragraph, I think 'should' should be replaced with 'must'.
> Otherwise, we would have to verify not only code itself but also its
> all possible usage.  This makes bug tracking awfully tedious (rather,
> substantially impossible).

GNUstep isn't responsible for tracking down faulty code outside GNUstep.
:)

> Suppose we find a bug in a method that returns BOOL values and that
> the method doesn't follow the proposed coding standard.  Because of
> 'should', this violation wouldn't be ruled out.  Then, we can
> attributes the bug to both the callee (code itself) and the caller
> (usage of the method).

The callee is correct; the problem is in the caller. However, I'm fine
with mandating that all methods in GNUstep that produce BOOLs only use
the values YES or NO. This would let users write code that uses GNUstep
and assumes that YES is the only true value (which is wrong, but it's
their code), and it doesn't affect correctness (all values should still
be accepted by GNUstep).

> If someone considers that the bug is due to
> the callee, then she/he is likely to begin a similar thread again:
> "The callee should not use a comparison against YES..."

Which is why we need to spell it out clearly in the coding standards. :)

- Alexander Malmberg




reply via email to

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