Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.3 alpha 4/3/85; site ukma.UUCP
Path: utzoo!watmath!clyde!cbosgd!ukma!david
From: david@ukma.UUCP (David Herron, NPR Lover)
Newsgroups: net.lang.c
Subject: Re: Cryptic C
Message-ID: <2083@ukma.UUCP>
Date: Sun, 25-Aug-85 02:37:23 EDT
Article-I.D.: ukma.2083
Posted: Sun Aug 25 02:37:23 1985
Date-Received: Sun, 25-Aug-85 14:02:14 EDT
References: <2913@ncsu.UUCP> <709@brl-tgr.ARPA> <1056@mtgzz.UUCP> <2076@ukma.UUCP> <685@gitpyr.UUCP>
Reply-To: david@ukma.UUCP (David Herron, NPR Lover)
Organization: Univ. of KY Mathematical Sciences
Lines: 47

In article <685@gitpyr.UUCP> robert@gitpyr.UUCP (Robert Viduya) writes:
>In article <2076@ukma.UUCP>, david@ukma.UUCP (David Herron, NPR Lover) writes:
>> Well, I personally prefer:
>> 
>> 	#define TRUE (1==1)
>> 	#define FALSE (1==0)
>> 	typedef char bool;
>> 
>> Which is succint, to the point, and *machine*independant*!
>> 
>
>Oh?  On what machine is (1==1) equal to 0, or (1==0) not equal to 0?  In
>section 7.6 (Relational operators, Appendix A - C Reference Manual from
>K&R's The C Programming Language), it explicitly states that the logical
>operators all yield 0 if the relation is false and 1 if the relation is
>true.  Nothing is mentioned about possible variations due to implementation
>machine differences.

I don't particularly care if it's defined to be machine independant already.

I have always thought that to be a machine dependancy (the value of true and
false).  Maybe I'm wrong.  But, different machines DO have different ideas
of which is true and false (at the assembler level).  And it is simply
a convention.

Still though, #define TRUE (1==1) is very obvious, to the point, correct,
proper, and all sorts of things.  And it doesn't require one to know
that detail about C that the convention is ~0 == TRUE and 0 == FALSE.

When I'm writing C I think of it has a *high*level*language*.  Not as 
simply one step away from assembler.  The difference between C and other 
*high*level*languages* is that it gives you precise control over an 
idealized machine.  This is what confuses most people about C, because
it can *feel* like assembler.  Especially when they've learned it on a 
PDP-11 and think like an assembly programmer.

But C gives you all these operators which allow you to define things
machine independantly rather than hardcoding values.  Obviously I mean
casts and the sizeof operator.  Also arithmetic to pointers.  So why not
TRUE and FALSE?
-- 
--- David Herron
--- ARPA-> ukma!david@ANL-MCS.ARPA
--- UUCP-> {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!david
---        {ihnp4,decvax,ucbvax}!cbosgd!ukma!david

Hackin's in me blood.  My mother was known as Miss Hacker before she married!