🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1504

Re: Incrementing a bool

#1504
From: Stephen Baynes
Date: Thu, 10 Aug 1995 07:23
35 lines
2557 bytes
Anselm Lingnau (lingnau@tm.informatik.uni-frankfurt.de) wrote:
: In article <9521600.9005@mulga.cs.mu.OZ.AU>,
: Fergus Henderson <fjh@munta.cs.mu.OZ.AU> wrote:

: There is a big difference between standardizing on one boolean type and
: adding it to the language as a built-in. Unfortunately, providing a
: boolean type at the library level does not help with the problem that
: some people would like conditional operators to return boolean instead
: of 0/1. This cannot be patched into the language without breaking lots
: of old code.

Provided an automatic conversion is made bool<->int then no code should break 
[it is effectivly an invisible change]. One could even make bool an itegral 
type like an enum with two values in which case the conversion comes for free.
For many people that is enough - it would stop the proliferation of bool like 
typedefs. I think that this is worth doing.

However to get any benifit of type checking one needs to restrict int->bool
conversion which would break some code. Provided one permits this to happen
automatically in the context of conditionals [ if() ?: && !! while() ]
and also allows ptr->bool in these contexts too then very little code will
break as these are the only places existing code would need to do this
conversion. If one started changing parameters to standard library functions 
to bool then this would cause code to break with restricted int->bool 
conversions.

Note there is nothing to stop compilers issueing warnings rather than errors 
for int->bool conversions and continuing to compile. There are enough ANSI 
compilers out there that still regard int<->ptr conversions as only a warning!

--
Stephen Baynes                              baynes@mulsoc2.serigate.philips.nl
Philips Semiconductors Ltd
Southampton                                 My views are my own.
United Kingdom
Technical Details
Message-ID: <DD3375.K46@ukpsshp1.serigate.philips.nl>
Path: arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynes
References: <1995Jul22.022031.10937@sq.sq.com> <3uuprl$frm@newsbf02.news.aol.com> <1995Jul26.030356.21528@sq.sq.com> <9521600.9005@mulga.cs.mu.OZ.AU> <409pcb$sfc@deneb.tm.informatik.uni-frankfurt.de>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++,comp.std.c
Path: arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynes
From: baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes)
Subject: Re: Incrementing a bool
Sender: news@ukpsshp1.serigate.philips.nl (account for localnews)
Message-ID: <DD3375.K46@ukpsshp1.serigate.philips.nl>
Date: Thu, 10 Aug 1995 07:23:29 GMT
References: <1995Jul22.022031.10937@sq.sq.com> <3uuprl$frm@newsbf02.news.aol.com> <1995Jul26.030356.21528@sq.sq.com> <9521600.9005@mulga.cs.mu.OZ.AU> <409pcb$sfc@deneb.tm.informatik.uni-frankfurt.de>
Organization: Philips Semiconductors, Southampton, UK
X-Newsreader: TIN [version 1.2 PL2]
Followup-To: comp.std.c++,comp.std.c