474,012 Members | 50,534 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Absense of bool

First of all: I love C and think that it's beautiful. However, there is
at least one MAJOR flaw: the lack of a boolean type.

OK. Some of you might refer to C99 and its _Bool (what's up with the
uppercase 'B' anyway?) and the header you can include (apparently) to
get a real "bool". This isn't my point, however -- it should have been
there from the beginning.

Char is a small int. We all know that. However, "char some_bool = 0;"
simply feels wrong, and I think that most of you agree. Plus, it's
still too large.

"int some_bool = 0;" is what I -- and everyone else, I assume -- use
for bools. But an int is a very large data type for something that will
only ever be true or false (1 or 0). This really, really bugs me.

Why, back when C was designed, didn't they see a reason to build in a
boolean type into the language? Now it matters less, I guess, but back
then, there should have been very strong technical reasons. It just
doesn't make any sense whatsoever to me.

I have asked many people about this for quite some time, and they are
all just telling me that I'm silly for bringing it up. Why? It's not
that I NEED a bool to get anything done -- it's the principle. Saving
resources and coding a little more prettily is a Good Thing (TM) IMO.

So... can somebody properly explain this to me once and for all? I'm
sure there MUST be a logical explanation that nobody seems to really
understand. The madness must end.

bool some_bool = 0; /* How great it would be... */

Nov 3 '07
51 2976
Chris Dollin wrote:
Richard wrote:
>What languages used GC at the time that C and its forefathers were
evolving?

Lisp, Algol W, Algol 68, Snobol (I think that's in the frame), Simula 67.
Off the top of my head, and not intended to be exhaustive by any means.
Argh! How could I forget POP2!

--
Chris "bows to Poplog" Dollin

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England

Nov 6 '07 #41
Chris Dollin <ch**********@h p.comwrites:
Chris Dollin wrote:
>Richard wrote:
>>What languages used GC at the time that C and its forefathers were
evolving?

Lisp, Algol W, Algol 68, Snobol (I think that's in the frame), Simula 67.
Off the top of my head, and not intended to be exhaustive by any means.

Argh! How could I forget POP2!
Yup all very C-like. What were the designers of C thinking!!!
Nov 6 '07 #42
In article <87************ @bsb.me.uk>,
Ben Bacarisse <be********@bsb .me.ukwrote:
Marvin L. Minsky. A Lisp garbage collector algorithm using serial
secondary storage. Technical Report Memo 58 (rev.), Project MAC, MIT,
Cambridge, MA, December 1963.
>I don't claim that this is the first paper on GC
The OED's first citation for "garbage collector" is 1960, McCarthy's
LISP I Programmer's Manual.

-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 6 '07 #43
In article <fg**********@m urdoch.hpl.hp.c om>,
Chris Dollin <ch**********@h p.comwrote:
>I think the timing fits, but I can't remember when RSRE did the first
A68 implementation. Certainly the technology was "well known".
It was RRE in those days. The "first published" date in the
ALGOL 68-R Users [sic] Guide is 1972.

-- Richard
--
"Considerat ion shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Nov 6 '07 #44
Richard wrote:
Chris Dollin <ch**********@h p.comwrites:
>Chris Dollin wrote:
>>Richard wrote:

What languages used GC at the time that C and its forefathers were
evolving?

Lisp, Algol W, Algol 68, Snobol (I think that's in the frame), Simula 67.
Off the top of my head, and not intended to be exhaustive by any means.

Argh! How could I forget POP2!

Yup all very C-like.
Was somebody asking for /C-like/ GCed languages? And what does "C-like" mean,
in the era before C?

--
Chris "BCPL" Dollin

Hewlett-Packard Limited registered no:
registered office: Cain Road, Bracknell, Berks RG12 1HN 690597 England

Nov 6 '07 #45
Chris Dollin <ch**********@h p.comwrites:
Richard wrote:
>Chris Dollin <ch**********@h p.comwrites:
>>Chris Dollin wrote:

Richard wrote:

What languages used GC at the time that C and its forefathers were
evolving?

Lisp, Algol W, Algol 68, Snobol (I think that's in the frame), Simula 67.
Off the top of my head, and not intended to be exhaustive by any means.

Argh! How could I forget POP2!

Yup all very C-like.

Was somebody asking for /C-like/ GCed languages? And what does "C-like" mean,
in the era before C?
We are talking about GC for C. Not for Lisp. Not for Algol. This is
getting to look like one of those fighting for points threads. I'll bow
out.

There was no need and no desire for GC in C. It would be like hanging an
anchor off the back of a skateboard.
Nov 6 '07 #46
Richard wrote:
Chris Dollin <ch**********@h p.comwrites:
>Richard wrote:
>>Chris Dollin <ch**********@h p.comwrites:

Chris Dollin wrote:

Richard wrote:
>
>What languages used GC at the time that C and its forefathers were
>evolving ?
>
Lisp, Algol W, Algol 68, Snobol (I think that's in the frame), Simula 67.
Off the top of my head, and not intended to be exhaustive by any means.

Argh! How could I forget POP2!

Yup all very C-like.

Was somebody asking for /C-like/ GCed languages? And what does "C-like" mean,
in the era before C?

We are talking about GC for C. Not for Lisp. Not for Algol.
It was you, was it not, who asked "What languages used GC at the time that
C and its forefathers were evolving?" Someone -- I've lost track of who --
claimed that "it didnt exist when C was invented". They were wrong, and I
took you to be asking for examples.

I answered that question.
There was no need and no desire for GC in C.
I've not said otherwise (and I think that "was" may be important).
It would be like hanging an anchor off the back of a skateboard.
Indeed.

One doesn't get motorcycles by merely adding engines to bicycles; effective
language design is holistic.

--
Chris "BSA Starfire, many years ago" Dollin

Hewlett-Packard Limited Cain Road, Bracknell, registered no:
registered office: Berks RG12 1HN 690597 England

Nov 6 '07 #47
Ben Bacarisse wrote:
I don't claim that this is the first paper on GC, just that it
pre-dates C. There are dozens of papers about GC from the 60s and DMR
cites 1969-73 as the key design time for C.
Ok. Thank you for the information...

I was basing on Richard's words when I wrote that (I didn't know when GC
had been invented).

JJ
Nov 6 '07 #48
On Sun, 04 Nov 2007 09:53:31 +0000, Philip Potter
<pg*@see.sig.in validwrote:
<snip>
Do you have an example of a language with a boolean type which will
store the boolean in a location smaller than a byte?
Pascal can use only 1 bit for a BOOLEAN and only the needed bits for a
(small) subrange or enum within an array or record, especially if you
declare it PACKED. At least in classic Pascal there is no way to take
the address of these so it doesn't matter that they aren't on a byte
(or word) boundary.

PL/I can do both of those for BIT(1), but AFAIK there's no syntax to
specify packing, so IMLE it is usually the default. (You can
explicitly declare padding, but it's hard to get it portably correct.)
PL/I also has BIT strings (fixed or variable-length=counted) which are
inherently packed, and whose elements cannot be pointed to (but can be
selected by SUBSTR).

Ada rather like Pascal has BOOLEAN and subrange/enum types, a general
option (pragma) for packing, and also more verbose options for exact
representation which allow you to really force desired packing.

- formerly david.thompson1 || achar(64) || worldnet.att.ne t
Nov 25 '07 #49
On Nov 4, 2:05 am, "J. J. Farrell" <j...@bcs.org.u kwrote:
On Nov 3, 10:56 pm, AommiK <nos...@nospam. comwrote:
First of all: I love C and think that it's beautiful. However, there is
at least one MAJOR flaw: the lack of a boolean type.
It's not
that I NEED a bool to get anything done -- it's the principle. Saving
resources and coding a little more prettily is a Good Thing (TM) IMO.

How would it save resources? A boolean type smaller than char would
require more resources to implement and at run time. How would it make
coding any prettier?
An array of Bool could save considerable resources, typically 87.5%,
if implemented as a bit-array. There would be implementation issues in
C however as a bit wouldn't be directly addressable.

Bart
Nov 26 '07 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2623
by: Pierre Espenan | last post by:
A have a long integer class. The built integer type within a conditional statement returns bool false for int i=0 and bool true for any other non zero value. I want my long integer class to have similar behavior. My class looks like this: #ifndef long_int_H #define long_int_H #include <string> using namespace std; typedef valarray<complex<double> > VCD;
19
3395
by: daniel | last post by:
1) is C++ smart enough to automatically use "bits" for bool or will a bool have the size of a charcter (byte). 2) The index of a vector is it an integer (4 byte) or a "long long" with 8 bytes or something else? I ask because I want to use vector<bool> with a few billion entries exceeding the int32 range for indexing and I want to use as few memory as possible for the whole
4
10771
by: ORC | last post by:
Is the bool type actually an Int32 with 0 as false and non zero as true? The reason for my question is that I've seen a lot of API calls that return a Int32 implemented in C# as an bool like: private static extern bool PurgeComm( Int32 hFile, UInt32 dwFlags); Thanks Ole
6
6876
by: zl2k | last post by:
hi, there I am using a big, sparse binary array (size of 256^3). The size may be changed in run time. I first thought about using the bitset but found its size is unchangeable. If I use the vector<bool>, does each element takes 4 bytes instead of 1 bit? I am using gcc3.4.4. There is a bit_vector which is kind of old so I wont use that. Any other choices? Thanks ahead. zl2k
64
3951
by: shaanxxx | last post by:
I have code which says #define MYBOOL int This code is very old. people who have written is not avaible. I was thinking what could be reason. 1) bool datatype was not available that time (10 years back: correct me if i am wrong) 2) int was word aligned (16bit and 32bit). Writter of above code doesnt want to give choice to compiler.
3
6344
by: markb | last post by:
Hi My C# app is being called from a callback from an unmanaged DLL. One of the parameters of the callback is of type BOOL. I am using PInvoke to marshal this to a (managed) bool. The problem is that no matter if we pass TRUE or FALSE, the bool is always marshalled as true. // unmanaged code in dll typedef bool (__stdcall *BoolCallBack)(short b);
0
10456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10273
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11528
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11823
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
11046
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8600
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7755
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6559
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6720
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.