home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / c / 16400 < prev    next >
Encoding:
Text File  |  1992-11-12  |  1.6 KB  |  36 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: <1992Nov12.125524.20896@druid.uucp>
  6. Date: Thu, 12 Nov 1992 12:55:24 GMT
  7. References: <1992Nov7.122126.24409@druid.uucp> <gm5XTB3w165w@quest.UUCP>
  8. Organization: D'Arcy Cain Consulting
  9. Lines: 25
  10.  
  11. srhqla!quest!kdq writes:
  12. >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. >    On the other hand, since C does not truly support the boolean type,
  17. >I consider it misleading to assign a numeric value to a boolean.  I
  18. >define TRUE as (1==1) because the result of this is a boolean - the
  19. >fact that it is represented by a numerical value is misleading.
  20.  
  21. Well as you say, C does not support the boolean type.  A true expression
  22. evaluates to 1 and a false to 0.  That's the definition of the language.
  23. (1==1) evaluates to 1 so it is the same as defining TRUE as 1.  If I see
  24. TRUE and FALSE in your code i *still* have to check that it is defined
  25. correctly.  The fact that your definition works is irrelevant, it still
  26. costs me time to confirm that.
  27.  
  28. To me it seems like defining SEVEN as 7.  It's correct but I wouldn't
  29. do it.
  30.  
  31. -- 
  32. D'Arcy J.M. Cain (darcy@druid.com)  |
  33. D'Arcy Cain Consulting              |   There's no government
  34. Toronto, Ontario, Canada            |   like no government!
  35. +1 416 424 2871          DoD#0082   |
  36.