[Top][All Lists]
[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...
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), (continued)
- Re: [RFA]: BOOL coding standards (Was: Problem with+numberWithBool: ?), Alexander Malmberg, 2004/01/31
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Kazunobu Kuriyama, 2004/01/30
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Richard Frith-Macdonald, 2004/01/30
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Richard Frith-Macdonald, 2004/01/30
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Adam Fedor, 2004/01/30
- Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Sheldon Gill, 2004/01/31
- Re[2]: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?), Manuel Guesdon, 2004/01/31
- Re: [RFA]: BOOL coding standards (Was: Problem with+numberWithBool: ?),
Alexander Malmberg <=
- Re: Problem with +numberWithBool: ?, Alexander Malmberg, 2004/01/30
- Re: Problem with +numberWithBool: ?, Nicola Pero, 2004/01/30
- Re: Problem with +numberWithBool: ?, Alexander Malmberg, 2004/01/30
- Re: Problem with +numberWithBool: ?, Philippe C.D. Robert, 2004/01/30
- Re: Problem with +numberWithBool: ?, Pascal J . Bourguignon, 2004/01/30
- Re: Problem with +numberWithBool: ?, Richard Frith-Macdonald, 2004/01/30
- Re: Problem with +numberWithBool: ?, Pascal J . Bourguignon, 2004/01/30
- Re[2]: Problem with +numberWithBool: ?, Manuel Guesdon, 2004/01/30