home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16861 < prev    next >
Encoding:
Internet Message Format  |  1992-11-20  |  3.8 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!Sirius.dfn.de!math.fu-berlin.de!unidui!Germany.EU.net!mcsun!sunic!seunet!volvo!risken!hansg
  2. From: hansg@risken.vd.volvo.se (Hans Granqvist)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: The Correct Way To Write C if-Statements
  5. Message-ID: <hansg.722248402@risken>
  6. Date: 20 Nov 92 08:33:22 GMT
  7. References: <140742@lll-winken.LLNL.GOV> <1992Nov6.225622.25460@dg-rtp.dg.com> <hansg.721510062@risken> <1992Nov12.212728.8864@dg-rtp.dg.com>
  8. Sender: news@vd.volvo.se
  9. Lines: 87
  10.  
  11. goudreau@batman.rtp.dg.com (Bob Goudreau) writes:
  12.  
  13. |In article <hansg.721510062@risken> hansg@risken.vd.volvo.se (Hans Granqvist) writes:
  14. |>goudreau@robin.rtp.dg.com (Bob Goudreau) writes:
  15. |>
  16. |>->    if ( OpenCode ) ...
  17. |>
  18. |>-Is anyone else as repelled as I am by the practice of leaving the
  19. |>-parentheses surrounded by whitespace on both sides?  Not only does
  20. |>-it violate such de-facto standards as K&R or H&S, it goes against
  21. |>-common English usage as well ( and if you don't believe that, then
  22. |>-tell me what's wrong with this parenthetical question? ) .
  23. |>
  24. |>Hmm... in my opinion, every person putting two (2) spaces at the end of
  25. |>a sentence ('full stop'?) not only breaks a de facto Swedish standard but also
  26. |>shows great unsolidity in his language. 
  27.  
  28. |"Unsolidity in his language"?  Whatever does that mean?
  29.  
  30. |Anway, if I were posting in Swedish, then perhaps I'd put only one
  31. |space after each period.  But in English, two following spaces *IS*
  32. |the standard (look it up).   And (getting back to the point), I'll
  33. |bet that even in Swedish you don't insert gratuitous spaces between
  34. |parentheses and the clause which they surround.
  35.  
  36. Firstly, two spaces is an American English standard. But, seriously,
  37. what I meant is that although you put some extra space at places I don't
  38. find 'regular' to my guidelines, I still can read your text.
  39. Relate that to C; an extra space doesn't really mean that much.
  40.  
  41. I think it is better if the code works OK.
  42.  
  43. |>-Moving on to another topic...
  44. |>
  45. |>->    if ( SomeDarnThing == TRUE ) ...
  46. |>
  47. |>-If "SomeDarnThing" (amazing how the whitespace fanatic seems to hate
  48. |>-underscores!) is a boolean variable, then what is the point of testing
  49. |>-it against TRUE or FALSE?  The following is more concise and easier
  50. |>-to read:
  51. |>
  52. |>-    if (some_darn_thing) ...
  53. |>
  54. |>
  55. |>Aye, relating to your latest remark on coherence with common language
  56. |>usage, is your proposed fashion more correct than the other? 
  57.  
  58. |I don't understand this comment.  The presence or absence of the
  59. |"== TRUE" code has no connection with punctuation conventions at all.
  60. |The thing which I find objectionable is the silly testing against
  61. |TRUE or FALSE.  Certainly the practice of using
  62.  
  63. |    if (condition)
  64.  
  65. |instead of
  66.  
  67. |    if (condition == 1)  /*  or == TRUE */
  68.  
  69. |is well established in C; look at K&R1.  So why add needless
  70. |verbiage?
  71.  
  72. I admit my comment was off track. There is no reference to my thought in
  73. written languages. Me and my mouth. I missed that you said boolean
  74. value.
  75.  
  76. But, I must object strongly to your
  77. saying that there's only need to test 'if' or 'if not'. Some FAQ I think
  78. once said (it still does, I presume) that there is a LOGICAL difference
  79. to 0, '\0', and NULL. So why not test against the correct values? After
  80. all, we are here to aid others understand our code when we are not
  81. around anymore... :-)
  82.  
  83. |>And, then, is there the slight casuality that 'TRUE' was defined to, per
  84. |>chance, '4711'?
  85.  
  86. |In which case there is the large *certainty* that the coder is an
  87. |idiot!  Anyone who defines TRUE and FALSE such that (! TRUE) isn't
  88. |equal to FALSE or (! FALSE) isn't equal to TRUE shouldn't be coding
  89. |in C.  The only pair of values that meet both conditions is 0 for
  90. |FALSE and 1 for TRUE.
  91.  
  92. 'idiot'? Perhaps he/she is just ill-educated? But you're right,
  93. reversing TRUE and FALSE should be supported in the language.
  94.  
  95. happy codeing,
  96. --
  97. Hans Granqvist, Volvo, Gothenburg, Sweden.
  98.