for(;;) vs. while(1) is a draw

Doug Gwyn gwyn at smoke.BRL.MIL
Sat May 26 17:22:32 AEST 1990


In article <4232 at castle.ed.ac.uk> aipdc at 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.



More information about the Comp.std.c mailing list