Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: Read errors

Re: Read errors

From: Henrik Backe <backe_at_swipnet.se>
Date: Fri, 14 Mar 2003 09:42:22 +0100

"Linus Nielsen Feltzing" wrote
> Mike Holden wrote:
> > The other option, where the function does not return a boolean, is to
make
> > this more obvious in the if statement, so the above becomes "if (0 !=
> > somefunction())", which makes the whole thing readable without hidden
> > macros, and also makes it obvious to the reader of the code that
> > somefunction() doesn't return a boolean, but an integer instead.
>
> I'm not sure I agree. The fairly experienced C programmer knows what's
> going on when he sees the "if(somefunction())" construct. He knows that
> any nonzero value is a true value, boolean or not. He should also be
> able to see from the context if a nonzero value is a success or not.
>

Not everyone are are experienced C programmers!
Personally I'm an experienced programmer but since I'm on a good (bad
really)
day have to read Cobal,Fortran,C,C++, ksh and csh code on three different
platforms
(Win32,OS/390 and Unix), I'm really gratefull for everything that avoids
possible
confusion.

> > That way
> > it helps the reader who is not intimately familiar with the code, who
may
> > not know (without checking the source for it) that somefunction()
returns
> > 0 for success.
>
> I don't see the difference. The if(func()) and the if(0 != func()) are
> the same thing, and I prefer the first one, because there is less fluff.
> The only issue is the "polarity" of the return code.
>

The only difference between them is that one contains hidden magic.

/Henrik
Received on 2003-03-14

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy