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: David Ayers
Subject: Re: [RFA]: BOOL coding standards (Was: Problem with +numberWithBool: ?)
Date: Sat, 31 Jan 2004 22:34:45 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113

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.

Cheers,
David




reply via email to

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