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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!wupost!csus.edu!netcomsv!mork!nagle
  3. From: nagle@netcom.com (John Nagle)
  4. Subject: Re: New C++ type: boole
  5. Message-ID: <-2lm4d#.nagle@netcom.com>
  6. Date: Mon, 27 Jul 92 17:58:04 GMT
  7. Organization: Netcom - Online Communication Services  (408 241-9760 guest) 
  8. References: <DOUGM.92Jul25234214@titan.cs.rice.edu>
  9. Lines: 41
  10.  
  11.       The notion that new reserved words should be added to C++ by 
  12. beginning them with a digit seem flawed.  Admittedly this avoids
  13. clashes with existing names.  But it suggests a move in a strongly
  14. undesirable direction.  Will the next new reserved word begin with
  15. a digit too? 
  16.  
  17.       It also may break programs which process C and C++ source text
  18. (formatters and such) because it changes the syntax of the basic
  19. lexical token.
  20.  
  21.       "true" and "false" are the way to go.  Compatability of old 
  22. programs can be handled by a simple trick.  Compilers should
  23. consider any form which defines "true" or "false" as a constant
  24. and effectively gives "true" a value of 1 or "false" a value of 0 to
  25. be a warning-only error.  
  26.  
  27.       Thus, a program which has
  28.  
  29.     #define true 1
  30.  
  31.       or
  32.  
  33.     const char true = 1;
  34.  
  35. will be automatically converted to the use of "boole" constants, because
  36. the old declarations will be ignored, with a warning.  Uses of "true"
  37. and "false" in the program in integer contexts will be automatically
  38. upgraded to "int", so the program will compile and function as before.
  39.  
  40.       Thus, "true" and "false" are fixed values, not redefinable.
  41. Unusual definitions of "true" and "false", such as
  42.  
  43.     const char false = -1;
  44.  
  45. should be considered illegal redefinitions of a reserved word.  Such
  46. usage is rare in C/C++, since it's incompatible with the usual operators.
  47.  
  48.        This approach will get "boole" into the language without pain, and
  49. without introucing strange symbols for the boolean operators.
  50.  
  51.                     John Nagle
  52.