Article View: comp.std.c
Article #1299Re: for(;;) vs. while(1) is a draw
From: Doug Gwyn
Date: Sat, 26 May 1990 07:22
Date: Sat, 26 May 1990 07:22
25 lines
1624 bytes
1624 bytes
In article <4232@castle.ed.ac.uk> aipdc@castle.ed.ac.uk (Paul D. Crowley) writes: >Peeve: why doesn't C have a type "boolean" built in? It seems natural, >and I'm sure there's some compiler somewhere that could use it to >improve executables. I think the only performance improvement one might expect would be the possibility of allocating smaller objects to hold type "boolean". This would be really handy on architectures that efficiently support bit arrays. (However, the lack of access to these from high-level languages has been one of the factors that has kept them from being widely implemented.) As I have mentioned before in comp.lang.c, practically all my applications #include <std.h>, where std.h is configured once per porting environment and mostly consists of macro definitions. Among other things it says typedef int bool; /* Boolean data */ #define false 0 #define true 1 which I use consistently, exactly as though these were keywords and as though C enforced a strict distinction between Boolean and integral types. E.g. if ( p != NULL ) not if ( p ) I find that this leads to more reliable code, since minor slipups in such things stand out like a sore thumb when I look at the code.
Technical Details
Message-ID:
<13003@smoke.BRL.MIL>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!haven!adm!smoke!gwynReferences:
<12986@smoke.BRL.MIL> <5907@buengc.BU.EDU> <4232@castle.ed.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!aplcen!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: for(;;) vs. while(1) is a draw Message-ID: <13003@smoke.BRL.MIL> Date: 26 May 90 07:22:32 GMT References: <12986@smoke.BRL.MIL> <5907@buengc.BU.EDU> <4232@castle.ed.ac.uk> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 25