C Style

00704a-Liber nevin1 at ihlpf.ATT.COM
Wed Apr 27 09:58:53 AEST 1988


In article <364 at m3.mfci.UUCP> karzes at mfci.UUCP (Tom Karzes) writes:

>TRUE should have the same type and value as the constant expression (0 == 0).
>Similarly, FALSE should have the same type and value as the constant
>expression (0 != 0).  This principle holds for any language.  In the case
>of C, TRUE and FALSE are signed 1 and signed 0, resp.

Since when does this principle hold for any language??  Take Fortran, for
instance.  If I remember correctly, odd numbers were TRUE and even numbers
were FALSE (or vice-versa; it's really been a long time since I used
FORTRAN), since compilers were required to look at only the least
significant bit when checking for true/false values.  (This may have been
changed for F77; I'm not sure.)

There are many other examples I could cite (Icon, LISP, etc.).  Your
principle only holds for languages which

a) Have a boolean type

and

b) All logical operations result in that boolean type

such as Pascal.  Many (most?) languages do not conform to these
requirements.
-- 
 _ __			NEVIN J. LIBER	..!ihnp4!ihlpf!nevin1	(312) 510-6194
' )  )				"The secret compartment of my ring I fill
 /  / _ , __o  ____		 with an Underdog super-energy pill."
/  (_</_\/ <__/ / <_	These are solely MY opinions, not AT&T's, blah blah blah



More information about the Comp.lang.c mailing list