home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16843 < prev    next >
Encoding:
Text File  |  1992-11-19  |  1.8 KB  |  58 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!sdd.hp.com!saimiri.primate.wisc.edu!doug.cae.wisc.edu!umn.edu!uum1!kksys.com!edgar!brainiac!lmt!aaronk.lmt.com!aaronk
  3. From: aaronk@county.lmt.mn.org (Aaron S. Kurland)
  4. Subject: Re: The Correct Way To Write C if-Statements
  5. Message-ID: <aaronk.193.722052372@county.lmt.mn.org>
  6. Sender: usenet@lmt.mn.org
  7. Nntp-Posting-Host: aaronk.lmt.com
  8. Organization: LaserMaster R&D
  9. References: <140742@lll-winken.LLNL.GOV> <1992Nov6.225622.25460@dg-rtp.dg.com> <604@ulogic.UUCP>
  10. Date: Wed, 18 Nov 1992 02:06:12 GMT
  11. Lines: 45
  12.  
  13. In article <604@ulogic.UUCP> hartman@ulogic.UUCP (Richard M. Hartman) writes:
  14.  
  15.     [ nasty spaces on both sides of parens examples deleted]
  16.  
  17. >I finally convinced 'em of the futility of this one though.  But they
  18. >still insist on:
  19.  
  20. >        if (x == y)
  21. >                flag = TRUE;
  22. >        else
  23. >                flag = FALSE;
  24.  
  25. >instead of believing that:
  26.  
  27. >        flag = (x == y);
  28.  
  29. >actually works.   What do you have to say about that one?
  30.  
  31. When I see this I just shake my head and laugh!
  32.  
  33. What do you think of this style?
  34.  
  35. if (cond)
  36. {
  37.    statement1;
  38. }
  39. else
  40. {
  41.    statement2;
  42. }
  43.  
  44. I always use the curlys even if there is only one statement in the block so 
  45. if I ever need to add another (or a debug statement) I can do it easily.  I 
  46. also like having the curly braces line up with the conditional statment.
  47.  
  48. Aaron
  49.  
  50. -----------------------------------------------------------------------------
  51. "Treasures to satiate desires both subtle and gross."
  52.                                         - Spalding Gray
  53.  
  54.   My company has not yet accepted my application for Corporate Spokesmodel.
  55.  
  56.         Mail: aaronk@county.lmt.mn.org       Flames: alt.dev.nul
  57. -----------------------------------------------------------------------------
  58.