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

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!uwm.edu!spool.mu.edu!agate!dog.ee.lbl.gov!horse.ee.lbl.gov!torek
  2. From: torek@horse.ee.lbl.gov (Chris Torek)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Hows this for odd
  5. Date: 11 Nov 1992 12:23:47 GMT
  6. Organization: Lawrence Berkeley Laboratory, Berkeley
  7. Lines: 31
  8. Message-ID: <27368@dog.ee.lbl.gov>
  9. References: <1992Nov9.102217.23060@monu6.cc.monash.edu.au> <BxGq4z.8oA@portal.hq.videocart.com> <1992Nov10.144922.13252@leland.Stanford.EDU> <1992Nov11.061508.21780@sq.sq.com>
  10. Reply-To: torek@horse.ee.lbl.gov (Chris Torek)
  11. NNTP-Posting-Host: 128.3.112.15
  12.  
  13. (I was hoping to stay out of this mess, but...)
  14.  
  15. I *can* think of one good use for
  16.  
  17.     i == 0 ? TRUE : FALSE
  18.  
  19. (instead of just `i == 0', or, for the terse among us, `!i').  In this
  20. one situation, however, I would probably spell `TRUE' and `FALSE'
  21. differently.
  22.  
  23. The situation I have in mind is a C-language implementation of some
  24. other (non-C) language, where the other language *has* a boolean type
  25. with specific values for `true' and `false'.  For instance, a Pascal
  26. system written in C might use something like:
  27.  
  28.     i == 0 ? V_TRUE : V_FALSE
  29.  
  30. to get the value nodes (which presumably would have some kind of
  31. aggregate type, or be an index into a table) for the `true' and `false'
  32. values.  These would be different nodes from, e.g., the integer
  33. constant `0' and the untyped pointer `nil' (which might be V_0 and
  34. V_NIL respectively).
  35.  
  36. The situation is not always clear-cut, and blanket statements like
  37. `a definition for TRUE is always bad' are bound to be false sometimes.
  38.  
  39. (For the most part, though, I do think `i == 0 ? TRUE : FALSE' is at
  40. best suspicious.)
  41. -- 
  42. In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 510 486 5427)
  43. Berkeley, CA        Domain:    torek@ee.lbl.gov
  44.