Ed Loehr <eloehr@austin.rr.com> writes:
> I see your examples demonstrate the danger of inappropriate or
> inattentive type conversion (e.g., splicing an int into a char), but I'm
> missing the danger you see, beyond a style offense, of "if (strcmp(foo,
> bar))"?
"if (strcmp(foo, bar))" is portable, no doubt about it. My point is
that the idiom encourages one to think of strcmp() as yielding bool,
which leads directly to the sort of thinko I exhibited. It's a
slippery-slope argument, basically.
I had always disliked the idiom on stylistic grounds, but I never quite
had a rational reason why. Now I do: it's a type violation. If C had
a distinction between int and bool then you'd not be allowed to write
this. As an old Pascal programmer I prefer to think of the two types
as distinct...
regards, tom lane