home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!wupost!csus.edu!netcomsv!mork!nagle
- From: nagle@netcom.com (John Nagle)
- Subject: Re: New C++ type: boole
- Message-ID: <-2lm4d#.nagle@netcom.com>
- Date: Mon, 27 Jul 92 17:58:04 GMT
- Organization: Netcom - Online Communication Services (408 241-9760 guest)
- References: <DOUGM.92Jul25234214@titan.cs.rice.edu>
- Lines: 41
-
- The notion that new reserved words should be added to C++ by
- beginning them with a digit seem flawed. Admittedly this avoids
- clashes with existing names. But it suggests a move in a strongly
- undesirable direction. Will the next new reserved word begin with
- a digit too?
-
- It also may break programs which process C and C++ source text
- (formatters and such) because it changes the syntax of the basic
- lexical token.
-
- "true" and "false" are the way to go. Compatability of old
- programs can be handled by a simple trick. Compilers should
- consider any form which defines "true" or "false" as a constant
- and effectively gives "true" a value of 1 or "false" a value of 0 to
- be a warning-only error.
-
- Thus, a program which has
-
- #define true 1
-
- or
-
- const char true = 1;
-
- will be automatically converted to the use of "boole" constants, because
- the old declarations will be ignored, with a warning. Uses of "true"
- and "false" in the program in integer contexts will be automatically
- upgraded to "int", so the program will compile and function as before.
-
- Thus, "true" and "false" are fixed values, not redefinable.
- Unusual definitions of "true" and "false", such as
-
- const char false = -1;
-
- should be considered illegal redefinitions of a reserved word. Such
- usage is rare in C/C++, since it's incompatible with the usual operators.
-
- This approach will get "boole" into the language without pain, and
- without introucing strange symbols for the boolean operators.
-
- John Nagle
-