Boolean Operators Slighted in C

VLD/VMB gwyn at BRL.ARPA
Sat May 10 06:52:37 AEST 1986


Steven Brian McKechnie Sargent <valid!sbs> says ("> ..."):
> A Boolean data type distinct from integers clutters the language with
> another (moderately useless) type and removes handy idioms like
> 	foo[x == 0] = bar;

Boolean quantities form an important abstract data type distinct from
counters, sets, real numbers, etc.  By not making the distinction,
the language encourages usage errors, the most notorious being
	if ( a = b )
		stuff;
Sure, one can make integers do double (or triple, or ...) duty,
but by now every programmer should realize the value of data
abstraction.

> New operators like "< =", in addition to being hard to spell and understand,
> facilitate usages that just aren't that common.  I hardly ever want to
> say x = (x < y), and I don't mind typing the extra characters.  I'm not
> interested in paying compiler vendors money for supporting this (or any
> other dubious misfeature pounded into the language for "completeness'
> sake.")

Here is an example where proper use of Boolean data would be violated.
A statement like
	x = x < y;
should NEVER be used, since it assigns a Boolean result to an
arithmetic variable.  This means that a "< =" operator is not
a good idea.

I find data abstraction to be a Good Thing, and have produced
much better code since defining a Boolean data type and using
it in a strictly type-correct manner.



More information about the Comp.lang.c mailing list