From: hansg@risken.vd.volvo.se (Hans Granqvist)
Newsgroups: comp.lang.c
Subject: Re: The Correct Way To Write C if-Statements
Date: 20 Nov 92 08:33:22 GMT

goudreau@batman.rtp.dg.com (Bob Goudreau) writes:

|In article <hansg.721510062@risken> hansg@risken.vd.volvo.se (Hans Granqvist) writes:
|>goudreau@robin.rtp.dg.com (Bob Goudreau) writes:
|>
|>->	if ( OpenCode ) ...
|>
|>-Is anyone else as repelled as I am by the practice of leaving the
|>-parentheses surrounded by whitespace on both sides?  Not only does
|>-it violate such de-facto standards as K&R or H&S, it goes against
|>-common English usage as well ( and if you don't believe that, then
|>-tell me what's wrong with this parenthetical question? ) .
|>
|>Hmm... in my opinion, every person putting two (2) spaces at the end of
|>a sentence ('full stop'?) not only breaks a de facto Swedish standard but also
|>shows great unsolidity in his language. 

|"Unsolidity in his language"?  Whatever does that mean?

|Anway, if I were posting in Swedish, then perhaps I'd put only one
|space after each period.  But in English, two following spaces *IS*
|the standard (look it up).   And (getting back to the point), I'll
|bet that even in Swedish you don't insert gratuitous spaces between
|parentheses and the clause which they surround.

Firstly, two spaces is an American English standard. But, seriously,
what I meant is that although you put some extra space at places I don't
find 'regular' to my guidelines, I still can read your text.
Relate that to C; an extra space doesn't really mean that much.

I think it is better if the code works OK.

|>-Moving on to another topic...
|>
|>->	if ( SomeDarnThing == TRUE ) ...
|>
|>-If "SomeDarnThing" (amazing how the whitespace fanatic seems to hate
|>-underscores!) is a boolean variable, then what is the point of testing
|>-it against TRUE or FALSE?  The following is more concise and easier
|>-to read:
|>
|>-	if (some_darn_thing) ...
|>
|>
|>Aye, relating to your latest remark on coherence with common language
|>usage, is your proposed fashion more correct than the other? 

|I don't understand this comment.  The presence or absence of the
|"== TRUE" code has no connection with punctuation conventions at all.
|The thing which I find objectionable is the silly testing against
|TRUE or FALSE.  Certainly the practice of using

|	if (condition)

|instead of

|	if (condition == 1)  /*  or == TRUE */

|is well established in C; look at K&R1.  So why add needless
|verbiage?

I admit my comment was off track. There is no reference to my thought in
written languages. Me and my mouth. I missed that you said boolean
value.

But, I must object strongly to your
saying that there's only need to test 'if' or 'if not'. Some FAQ I think
once said (it still does, I presume) that there is a LOGICAL difference
to 0, '\0', and NULL. So why not test against the correct values? After
all, we are here to aid others understand our code when we are not
around anymore... :-)

|>And, then, is there the slight casuality that 'TRUE' was defined to, per
|>chance, '4711'?

|In which case there is the large *certainty* that the coder is an
|idiot!  Anyone who defines TRUE and FALSE such that (! TRUE) isn't
|equal to FALSE or (! FALSE) isn't equal to TRUE shouldn't be coding
|in C.  The only pair of values that meet both conditions is 0 for
|FALSE and 1 for TRUE.

'idiot'? Perhaps he/she is just ill-educated? But you're right,
reversing TRUE and FALSE should be supported in the language.

happy codeing,
--
Hans Granqvist, Volvo, Gothenburg, Sweden.
Newsgroups: comp.lang.c