home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / c / 16485 < prev    next >
Encoding:
Internet Message Format  |  1992-11-14  |  2.1 KB

  1. Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!kronos.arc.nasa.gov!iscnvx!netcomsv!ulogic!hartman
  2. From: hartman@ulogic.UUCP (Richard M. Hartman)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to use 'return' in c?
  5. Message-ID: <603@ulogic.UUCP>
  6. Date: 14 Nov 92 01:36:56 GMT
  7. References: <1992Oct29.025437.9289@nuscc.nus.sg> <1992Nov2.203701.162@ipact.com> <1992Nov7.122126.24409@druid.uucp>
  8. Organization: negligable
  9. Lines: 45
  10.  
  11. In article <1992Nov7.122126.24409@druid.uucp> darcy@druid.uucp (D'Arcy J.M. Cain) writes:
  12. >allebrandi@ipact.com writes:
  13. >>The best thing to do is to use manifest constants to implicitly document
  14. >>the value you are returning. For example, return TRUE or FALSE not 1 or
  15. >>0 for a boolean function return.
  16. >
  17. >Whenever I see TRUE and FALSE in code I am maintaining I remove the
  18. >#defines.  If they are defined, they should never be anything but
  19. >TRUE = 1 and FALSE = 0.  Anything else is confusing and misleading.
  20. >Given this why force the maintainer to go searching for the definitions
  21. >to make sure that they are what they should never be anything but?
  22. >This isn't as bad as #defining SEVEN as 7 but it is in the same category
  23. >I think.
  24.  
  25. Wait a sec.... are you saying that if I have
  26.  
  27.     setFlagValue(TRUE);
  28.  
  29. somewhere you come along and change it to:
  30.  
  31.     setFlagValue(1);
  32.  
  33. ??????
  34.  
  35. You consider that this is easier to maintain?????
  36.  
  37. It removes the intent behind the value!  "TRUE" shows intent to
  38. use a boolean type (which does not exist in C), and that the
  39. function is expecting a truth value of some sort.  Using "1"
  40. is misleading in that the next person to come along only knows
  41. that this function accepted some integer value without any
  42. clue that it was primarly a truth value.
  43.  
  44. If I misunderstood your statement:
  45.     "Whenever I see TRUE and FALSE in code I am maintaining 
  46.     I remove the #defines"
  47.  
  48. I apologize for this post.  But to me the statement is a bit
  49. unclear in it's intent. :)
  50.  
  51. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  52. Blasting, bursting, billowing forth with    |
  53. the power of ten billion butterfly sneezes,    |    -Richard Hartman    
  54. Man, with his flaming fire,            |    hartman@uLogic.COM
  55. has conquered the wayword breezes.        |
  56.