🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: stop adding keywords to C++

#2837
From: Steve Clamage
Date: Mon, 04 Dec 1995 22:16
66 lines
3220 bytes
In article 100000@barney, mzhou01 <mzhou01@barney.poly.edu> writes:
>C++ standardization people,
>
>With all respect. I am not happy with the way the committe is 
>modifying the C++ language. I think you people are enlarging the language 
>by adding un-
>necessary keywords to it. For example the boolean type, true, false keywords. 
>I spoke to my university friends about this addendum and they feel the
>say way as I do. Why do we need in boolean type? If it was really
>necessary Dennis Ritchie would have put it in C in the place.

If classes were necessary, Ritchie would have put them into C. If
templates were necessary, ... and so on. That isn't much of an argument.
You can program in binary machine language, so even C isn't necessary.

In fact, the absence of a boolean type in C has been keenly felt and
remarked on by many writers about C. Its lack causes many programmers
to provide their own typedefs and #defines, all conflicting.

What do you do when two or more packages you want to use in the same
program all have conflicting typedefs or #defines? E.g.,
	typedef int bool;
	typedef short bool;
	typedef char bool;
	#define bool int;
	#define true 1
	#define false 0
	const int true = 1;
	const int false = 0;
	enum bool { false, true };
This is one reason why the boolean type was added to C++.

The other reason is that no user definition of a boolean type can
satisfy all the requirements to allow function overloading on a boolean
type. For example:
	f(bool b) { ... } //  when bool is not built in
	f(int b) { ... }
At this point, the code won't even compile if bool is a typedef for int.
Let's assume it is some other type.
	foo(int i)
	{
		bool b = i < 3;
		f(b); // calls f(bool)
		f( i < 3 ); // calls f(int) -- unexpected result
		...
	}

Only two real solutions are possible:
	1. Don't try to use a boolean type in C++, since it doesn't
		really exist, and the attempts to create a user-defined
		type cause more problems than they solve.
	2. Create a full-fledged boolean type built into the language.

Solution 1 was status quo, and was judged by a great many people to be
inadequate. Hence we adoped solution 2. (For most practical purposes,
putting a boolean type in the standard library instead would be equivalent.
It doesn't have any advantages over using keywords that I can see.)

---
Steve Clamage, stephen.clamage@eng.sun.com



[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <49vplf$mvs@engnews2.Eng.Sun.COM>
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
References: <Pine.SOL.3.91.951203010216.13007A-100000@barney>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
From: clamage@Eng.sun.com (Steve Clamage)
Newsgroups: comp.std.c++
Subject: Re: stop adding keywords to C++
Date: 4 Dec 1995 22:16:32 GMT
Organization: Sun Microsystems Inc.
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <49vplf$mvs@engnews2.Eng.Sun.COM>
References: <Pine.SOL.3.91.951203010216.13007A-100000@barney>
Reply-To: clamage@Eng
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: taumet.eng.sun.com
Content-Length: 2370
X-Lines: 62
Originator: clamage@taumet