🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Incrementing a bool

#1494
From: Anselm Lingnau
Date: Fri, 04 Aug 1995 12:53
40 lines
2625 bytes
In article <KANZE.95Aug3174437@slsvhdt.lts.sel.alcatel.de>,
James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de> wrote:

> I agree that with experience, one can get used to
> reading anything, but why this insistance on making it hard for the
> reader?

Well, nobody *forces* you to say `if (ptr)'. You can always put in the
explicit comparison if you're feeling nice :^)

> The analogy with characters in Pascal breaks down in that the compiler
> never needs a character type; the type *doesn't* exist in C (yet). [...]

I still don't see a fundamental difference between the convention that
`0' is taken as `false' and `non-0' is taken as `true' in conditionals
and the convention that certain (small, as yet) integers correspond to
characters that you can print.

If anything, the `char' situation is worse: there is no guarantee that
the value 65 will get you an `A', for example, while the correspondence
between integers and `truth values' is fixed. And what sense is there in
having a `char' type that you can *increment* -- in a German locale,
should `char c = 'A'; ++c' give you `B' or `A-umlaut'? This seems to me
ample justification for a true character type where such operations are
outlawed, so we can avoid subtle errors :^)

> That's one solution, but it doesn't work in C++ due to function
> overloading.  I will admit, however, that there is a definite conflict
> between what I would really like to have, and what to do with existing
> code.

I can see the justification for a built-in Boolean type as far as C++
is concerned. IMHO, it does not follow that C needs to go along with it.
C is nice, comparatively simple and *small*. Keep it that way.

Anselm
-- 
Anselm Lingnau ......................... lingnau@tm.informatik.uni-frankfurt.de
Windows/NT - From the people who brought you EDLIN.
                                              --- Herb.Peyerl@novatel.cuc.ab.ca
Technical Details
Message-ID: <3vt593$8p7@deneb.tm.informatik.uni-frankfurt.de>
Path: arc1-ca.pugleaf.net!zeus.rbi.informatik.uni-frankfurt.de!not-for-mail
References: <KANZE.95Jul19114530@slsvhdt.lts.sel.alcatel.de> <KANZE.95Jul26122240@slsvhdt.lts.sel.alcatel.de> <3va81j$b4c@deneb.tm.informatik.uni-frankfurt.de> <KANZE.95Aug3174437@slsvhdt.lts.sel.alcatel.de>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!zeus.rbi.informatik.uni-frankfurt.de!not-for-mail
From: Anselm Lingnau <lingnau@tm.informatik.uni-frankfurt.de>
Newsgroups: comp.std.c++,comp.std.c
Subject: Re: Incrementing a bool
Date: 4 Aug 1995 14:53:55 +0200
Organization: Dept. of Computer Science, University of Frankfurt, Germany
Sender: lingnau@deneb.tm.informatik.uni-frankfurt.de
Message-ID: <3vt593$8p7@deneb.tm.informatik.uni-frankfurt.de>
References: <KANZE.95Jul19114530@slsvhdt.lts.sel.alcatel.de> <KANZE.95Jul26122240@slsvhdt.lts.sel.alcatel.de> <3va81j$b4c@deneb.tm.informatik.uni-frankfurt.de> <KANZE.95Aug3174437@slsvhdt.lts.sel.alcatel.de>
NNTP-Posting-Host: deneb.tm.informatik.uni-frankfurt.de