[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Use true/false or TRUE/FALSE in KDE C++ programs?
From:       Richard Dale <Richard_Dale () tipitina ! demon ! co ! uk>
Date:       2005-05-29 15:34:24
Message-ID: 200505291734.24651.Richard_Dale () tipitina ! demon ! co ! uk
[Download RAW message or body]

On Sunday 29 May 2005 17:55, André Wöbbeking wrote:
> On Sunday 29 May 2005 16:02, Richard Dale wrote:
> > On Sunday 29 May 2005 16:48, André Wöbbeking wrote:
> > > On Sunday 29 May 2005 15:36, Richard Dale wrote:
> > > > I hate code which type puns ints into booleans such as:
> > > >
> > > > if !strcmp("mything", "myotherthing') {
> > > > 	..other difficult to read crap code
> > > > }
> > >
> > > this is a bad example as strcmp() returns a tristate: less, equal
> > > or greater but I know what you mean.
> >
> > Well, it's a good example because it's so bad.. :)
>
> Would
>
>   if (strcmp("mything", "myotherthing') == 0)...
>
> help you if you don't know how strcmp() works? If old C had supported
> inlining they had probably strless(), strequal() and strgreater().
Of course I know how strcmp works - I've been programming C since 1987 or so.. 
But I like my code to be blindingly obvious to maintainers, and I can just 
look at the above expression to see what it means. An !strcmp() expression is 
something else again, and I haven't the faintest idea why a good programmer 
would want to use this idiom.

-- Richard
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic