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: Sun, 01 Feb 2004 04:05:51 +0100

Richard Frith-Macdonald wrote:
> On 30 Jan 2004, at 16:00, Alexander Malmberg wrote:
> > I've attached a patch to our coding standards. OK to commit? If so, new
> > code will work ok, and I'll get to work on patching core/ (hopefully
> > with some help from David Ayers :).
> 
> Predictably perhaps,  I don't really like it ...
> 
> I think the idea a boolean type is an improvement over C,

But BOOL isn't a boolean type. _Bool is.

> and it worries
> me that being too tolerant will encourage bad coding (and may make
> the code less readable).

This is interesting, because I see these two faults in your preferred
way of doing this: bad code because it doesn't handle truth values
correctly, and less readable because it clutters the code with
unnecessary comparisons. The latter is just a style issue, so I don't
care much about it, but the former is a correctness issue, as far as I'm
concerned.

As it turns out, this isn't as obvious as I thought it'd be. Thus, we
should decide which it is and clearly document it in the coding
guidelines. Either booleans are normal c truth values, or booleans may
only have the values YES (1) or NO (0).

> If we want to mandate a standard way of testing the results of an
> operation
> which is supposed to return a BOOL, perhaps use of a macro might be
> better.
> eg.
> 
> if (IsYes([receiver aMessage])) ...

Please, no! This is even worse clutter.

- Alexander Malmberg, still reeling...




reply via email to

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