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: Richard Frith-Macdonald
Subject: Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?)
Date: Sun, 1 Feb 2004 07:13:15 +0000


On 31 Jan 2004, at 21:34, David Ayers wrote:

David Ayers wrote:
Richard Frith-Macdonald wrote:
[snip]
However, while the definition above *might* be appropriate for production code, I think it is wrong for a development system, and certainly if NDEBUG is not defined I think it should be of the form -

#define isYES(_exp) ((_exp) == YES) ? 1 : (((_exp) == 0) ? NO : ([NSException raise...],0)

Well, actually this will probably have to be done in a (static inline) function to avoid evaluating the expression mutliple times ...

Just to clarify, I don't mean making isYES a function, I mean:

#ifndef isYES
#ifndef NDEBUG
#define isYES (_exp) (_exp != NO)
/* or even just:     (_exp)       if exp != NO is such a bad style. */
#else
#define isYES (_exp) (_GSAssertBOOL(_exp))
#endif
#endif
...
STATIC_INLINE BOOL
_GSAssertBOOL(BOOL val)
{
  return (val == YES ? 1 : ((val == NO) ? NO
    : ([NSException raise...],0))
}
or something similar.

I would be quite happy with this ... but I'm not sure about other people.

I would also be happy if we could change BOOL to be the same as the _Bool type Alexander mentioned (preferably with a compiler option to warn about possibly bad assignments), but that would require co-operation from Apple and gcc people of course.

Do you think it's worth contacting someone from Apple?





reply via email to

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