On Mon, Nov 26, 2007 at 11:52:00PM +0100 I heard the voice of
Rhialto, and lo! it spake thus:
> 
> I read "if (x) ..." as "if there is an x, ..." which maps nicely to
> both integral and pointer types for x.

Except when people get confused (as I've done, and as I've seen other
people do) with regards to signed values.  And when expressions get
more complex than just a variable.  And very much when adding
negations.  See for instance in vscreen.c:CtwmSetVScreenMap(); saying
"if(tally==0)" would be a lot clearer than "if(!tally)"[0].  I
certainly find that "if(foo==NULL)" is a lot more obvious than
"if(!foo)".  And don't get me started on when people writen
"if(!strcmp(...))", which means just the opposite of your immediate
impression.  Explicit comparisons make it immediately obvious what
you're checking.


I read "if(x)" as "if x" and then have to take a mental fault to
figure out "if x...   if x what?"  It works out OK if the condition is
named to obviously be a predicate, and designed as nothing else (e.g.,
"if(__isthreaded)" or "else if(user_can_alter(foo))"; a fair number of
C coding standards I've seen mandate no explicit comparison for
obvious predicates, and require the comparison when it's not).  But
anything else always leads me to walking back over the code to double
check types and figure out what the meaning behind the assertion is.
Probably, some of my hatred for the construct is influenced by even
more egregious abuses in other languages.


> Etcetera ad absurdum.

Absurdum indeed.  My brain is not a C compiler.



[0] Really, I wanna yank that variable entirely; it's not necessary.
    And then there's the buffer overflow just waiting to happen in
    that function...  there seems plenty of cleanup to occupy all my
    round tuit holes   :]


-- 
Matthew Fuller     (MF4839)   |  [EMAIL PROTECTED]
Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
           On the Internet, nobody can hear you scream.

Reply via email to