home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11603 < prev    next >
Encoding:
Text File  |  1992-07-27  |  2.7 KB  |  59 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!pmafire!news.dell.com!natinst.com!cs.utexas.edu!csc.ti.com!tilde.csc.ti.com!mksol!mccall
  3. From: mccall@mksol.dseg.ti.com (fred j mccall 575-3539)
  4. Subject: Re: New C++ type: boole
  5. Message-ID: <1992Jul27.135243.28686@mksol.dseg.ti.com>
  6. Organization: Texas Instruments Inc
  7. References: <DOUGM.92Jul26200316@titan.cs.rice.edu> <9220914.11530@mulga.cs.mu.OZ.AU>
  8. Date: Mon, 27 Jul 1992 13:52:43 GMT
  9. Lines: 48
  10.  
  11. In <9220914.11530@mulga.cs.mu.OZ.AU> fjh@mundil.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
  12.  
  13. >The following is actually from Deviasse Robert N <a228devi@cdf.toronto.edu>.
  14. >I am posting it for him, since he does not have write access to the net.
  15. >Disclaimer: if you don't like it, blame him! :-)
  16.  
  17. >    Fergus.
  18.  
  19. >========================== PROPOSAL FOLLOWS =============================
  20.  
  21. >Actually there is a general way of adding a boole type without breaking any
  22. >C++ code. Every DOS compiler I've used (and a few UNIX ones) already give
  23. >warning for code such as "if (ch=getchar()) /*...*/;". Such warnings could
  24. >easiliy be made manditory in the standard, or the standard could reserve
  25. >a pragma that does this type of checking, though the implementation may
  26. >choose not to implement it. 
  27.  
  28. NO!  Do *NOT* make this warning mandatory.  Some of us prefer to write
  29. code like this on purpose.  Accidently using '=' where I meant '=='
  30. has never been a problem for me, and I find 'if (x=f(z))' to be a much
  31. more concise statement of what I want (if f(z) returns a zero or null
  32. pointer, do the body of the if; whatever happens, assign the returned
  33. value to z) than having to parenthesize and then add an explicit
  34. comparison to 0 for the 'if'.
  35.  
  36. This is one warning that I always turn off in PC compilers.  Pure
  37. annoyance. 
  38.  
  39. >I think that most people would like to have a boolean type in C++, although
  40. >most people have resigned themselves to thinking that boolean types
  41. >cannot easily be added to C++.
  42.  
  43. The only 'advantage' I can see to a 'real' boolean type is if you can
  44. guarantee me that it will only take up one bit and the compiler is
  45. bright enough to store them all off in some bit array someplace to
  46. save space.  Otherwise, I guess I fail to see any pressing need for
  47. this.
  48.  
  49. I think there are a lot better ideas than this to expend effort on
  50. (things like real subrange types, for example, which would allow
  51. 'bool' to be implemented as a subrange from 0..1, for folks who really
  52. feel like the need bool).
  53.  
  54. -- 
  55. "Insisting on perfect safety is for people who don't have the balls to live
  56.  in the real world."   -- Mary Shafer, NASA Ames Dryden
  57. ------------------------------------------------------------------------------
  58. Fred.McCall@dseg.ti.com - I don't speak for others and they don't speak for me.
  59.