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

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!utcsri!torn!utzoo!telly!druid!darcy
  3. From: darcy@druid.uucp (D'Arcy J.M. Cain)
  4. Subject: Re: How to use 'return' in c?
  5. Message-ID: <1992Nov17.033541.10382@druid.uucp>
  6. Date: Tue, 17 Nov 1992 03:35:41 GMT
  7. References: <1992Nov2.203701.162@ipact.com> <1992Nov7.122126.24409@druid.uucp> <603@ulogic.UUCP>
  8. Organization: D'Arcy Cain Consulting
  9. Lines: 53
  10.  
  11. hartman@ulogic.UUCP (Richard M. Hartman) writes:
  12. >In article <1992Nov7.122126.24409@druid.uucp> darcy@druid.uucp (D'Arcy J.M. Cain) writes:
  13. >>Whenever I see TRUE and FALSE in code I am maintaining I remove the
  14. >>#defines.  If they are defined, they should never be anything but
  15. >>TRUE = 1 and FALSE = 0.  Anything else is confusing and misleading.
  16. >Wait a sec.... are you saying that if I have
  17. >    setFlagValue(TRUE);
  18. >somewhere you come along and change it to:
  19. >    setFlagValue(1);
  20.  
  21. After I make sure that TRUE is defined as 1.  If it isn't I change the
  22. name to something else.  I really don't feel like looking it up more
  23. than once.  I certainly don't have any problem with a function name
  24. like "setFlagValue()."  It's pretty obvious that a function with a
  25. name like that is looking for a true or false value.
  26.  
  27.  
  28. >You consider that this is easier to maintain?????
  29.  
  30. Yes.  Why so shocked?
  31.  
  32. >It removes the intent behind the value!  "TRUE" shows intent to
  33. >use a boolean type (which does not exist in C), and that the
  34.                      ^^^^^^^^^^^^^^^^^^^^^^^^^
  35. Exactly.
  36.  
  37. >function is expecting a truth value of some sort.  Using "1"
  38. >is misleading in that the next person to come along only knows
  39. >that this function accepted some integer value without any
  40. >clue that it was primarly a truth value.
  41.  
  42. If it matters they probably have to know more about the function
  43. than that it takes some sort of integral value.  
  44.  
  45. >If I misunderstood your statement:
  46. >    "Whenever I see TRUE and FALSE in code I am maintaining 
  47. >    I remove the #defines"
  48.  
  49. Well that may be a bit strong I suppose.  I mean I don't make wholesale
  50. changes to code that I am making one or two trivial changes to but if
  51. it is something that I am doing a major rewrite to then yes that would
  52. be one of the early candidates for cleanup.
  53.  
  54. >I apologize for this post.  But to me the statement is a bit
  55. >unclear in it's intent. :)
  56.  
  57. But it is a TRUE statement.  :-)
  58.  
  59. -- 
  60. D'Arcy J.M. Cain (darcy@druid.com)  |
  61. D'Arcy Cain Consulting              |   There's no government
  62. Toronto, Ontario, Canada            |   like no government!
  63. +1 416 424 2871          DoD#0082   |
  64.