Definition of boolean type

Leslie Mikesell les at chinet.chi.il.us
Mon Feb 13 08:30:15 AEST 1989


In article <27989 at ucbvax.BERKELEY.EDU> jas at ernie.Berkeley.EDU.UUCP (Jim Shankland) writes:

>I agree with Karl Heuer:  C would have benefited from a built-in boolean
>type.

Or perhaps a boolean equality operator for people who don't like the looks
of:
(1)    if (expression) action();
and prefer:
(2)    if (expression == SOMETHING) action();
and who don't like:
(3)    if (expression != 0) action();

Method (2) would work (and look better to some people) if C had a boolean
equality operator that would evaluate false only when one of the operands
is zero and one non-zero.  This would have an advantage over a separate
data type in that you would not have to convert the return values from
all those functions that return 0 for failure, some (useful, non-boolean)
value on success.

Les Mikesell



More information about the Comp.lang.c mailing list