C Style (Was Re: == vs =)
Alan J Rosenthal
flaps at dgp.toronto.edu
Mon Apr 25 04:07:13 AEST 1988
People complaining recently that "if(expr == TRUE)" is ridiculous have
missed the most convincing reason as to why it is ridiculous. Note
that we are assuming that expr is a boolean expression in the
Indian-Hill-C-Style-Manual-as-annotated-by-Henry-Spencer sense that it
is known to evaluate to one of 0 or 1.
The clearest reason why "if(expr == TRUE)" is ridiculous is simply that
such a test begs the question. Certainly "expr == TRUE" returns a
boolean result, so if it is necessary to test boolean results in this
fashion then we must write "if((expr == TRUE) == TRUE)"! And so on,
making the expression infinitely large, which is explicitly prohibited
by the ANSI C standard.
ajr
--
"The goto statement has been the focus of much of this controversy."
-- Aho & Ullman, Principles of Compiler Design, A-W 1977, page 54.
More information about the Comp.lang.c
mailing list