Boolean Operators Slighted in C
Frank Adams
franka at mmintl.UUCP
Mon May 26 12:35:07 AEST 1986
In article <822 at brl-smoke.ARPA> rbj%icst-cmr at smoke.UUCP writes:
> 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.
>
>This fact doesn't bother people who write in APL, widely considered
>to be the most mathematical language. Why does it bother you?
When I was writing in APL, I found that a necessary part of writing good
code was always knowing what the data I was dealing with was. (This doesn't
mean that one cannot write a function which works for more than one data
type; just that one must explicitly know that that is what one is writing.)
If I wrote AxB, I knew whether A was a Boolean or a number; the ability to
declare it could only have helped.
The fact that one can map Booleans into numbers, and thereby get a number of
Boolean operators from the arithmetic ones, is one of those great mixed
blessings. There is a real loss in readability when one takes advantage of
such things, as C and APL both do.
I think Pascal and ADA are closer to the mark here, regarding Boolean as an
instance of an enumeration type. This is not merely clever; it is correct.
Frank Adams ihnp4!philabs!pwa-b!mmintl!franka
Multimate International 52 Oakland Ave North E. Hartford, CT 06108
More information about the Comp.lang.c
mailing list