home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!apple!apple!netcomsv!ulogic!hartman
- From: hartman@ulogic.UUCP (Richard M. Hartman)
- Newsgroups: comp.lang.c++
- Subject: Re: boolean (was: Re: typedef vs enum)
- Message-ID: <147@ulogic.UUCP>
- Date: 23 Jul 92 17:50:27 GMT
- References: <DOUGM.92Jul17133255@titan.cs.rice.edu> <1992Jul18.193943.3804@taumet.com> <1992Jul19.142813.9295@ucc.su.OZ.AU>
- Organization: negligable
- Lines: 37
-
- In article <1992Jul19.142813.9295@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- >In article <1992Jul18.193943.3804@taumet.com> steve@taumet.com (Steve Clamage) writes:
- >>If you come up with a proposal, please remember that existing code
- >>which assumes 0/1 int results for || && ! operators should still work.
- >>Such code should also work in if/while/for/switch control expressions.
- >>So should expressions of type boolean.
- >
- > It follows that pointers and numbers MUST convert to
- >type boolean automatically.
-
- Why? Couldn't we overload || && and ! to return bool?
-
- > Now there is only ONE decision left:
- >
- > should boolean convert to int without an explicit cast?
-
- This we DO need, since we cannot overload "if", and if we want
-
- to write
- bool cond;
-
- if (cond)
- something;
-
- I *think* we need to provide auto-conversion from bool to int.
-
-
- > I say yes, although such a boolean type is hardly
- > isolated from integral types!
-
- Since I have suggested NO auto conversion from int-->bool we
- still have some isolation. You can use a bool where an int
- may be expected (such as in "if"), but NOT (without casting)
- use an int where a bool is expected!
-
- Of course, if the compiler accepts a bool in an "if" condition
- w/o providing a bool-->int auto-conversion even better.
-