Definition of boolean type

Steve Summit scs at adam.pika.mit.edu
Sun Feb 19 10:34:34 AEST 1989


In article <7698 at chinet.chi.il.us> les at chinet.chi.il.us (Leslie Mikesell) writes:
>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();
>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.

How silly.  The thing to do is educate those "people who don't
like the looks of if(expression)".  Who are they, anyway?
If an expression is of "conceptual type boolean," and especially
if its name reflects it ("inputready()", "break_seen", etc.) then
if(expression) is the most natural way to write it.  If the
expression is not "conceptually boolean," then an explicit
comparison is correct and appropriate.

Comparison operators can be thought of as converting ints to
bools, to be handed to things like "if".  Who needs a new
operator to convert bools to bools?

                                            Steve Summit
                                            scs at adam.pika.mit.edu



More information about the Comp.lang.c mailing list