more on TRUE and FALSE (side-comment)

Thomas Weiske weiske at lan.informatik.tu-muenchen.dbp.de
Fri Sep 28 21:16:22 AEST 1990


I use some very useful header files because I cant remember
the actual encoding of TRUE/FALSE. Actually I cant remember
the correct writing of True or False, sometimes I prefer
true and false depending on the context to get a nice C 
Program Layout.
Here is the first one:
---x---x---x---x---x---x---x---x---x---x---
#define TRUE	((0)==(0))
#define True	TRUE
#define true	True
#define FALSE	((1)==(2))
#define False	FALSE
#define false	False
---x---x---x---x---x---x---x---x---x---x---
To make the definitions more tolerant to typos
you can add
'Treu' or 'Fasle' a.s.o.
The interesting thing is the compatibility to
all in this newsgroup suggested encodings of 
TRUE and FALSE without any loss of runtime speed!

I also use many loops in my programs, but I dont like
while(1), while(TRUE) or for(;;).
This looks ugly and does not express the real meaning
of the loop.
I prefer:
---x---x---x---x---x---x---x---x---x---x---
#define ever	(;;)
---x---x---x---x---x---x---x---x---x---x---
Now you can write:
	for ever {Stuff}
I like it much more than 'forever' and the header
file is 6 Bytes shorter!

Now here is my solution to the self printing C program:
---x---x---x---x---x---x---x---x---x---x---
#include <stdio.h>
main(){
  int c; FILE *f=fopen(__FILE__,"r");
  while(f&&(c=getc(f))!=EOF)putchar(c);
}
---x---x---x---x---x---x---x---x---x---x---

--
Thomas Weiske                        | Phone +89/2105 8136
weiske at lan.informatik.tu-muenchen.de | Fax   +89/2105 8180
Technische Universit"at M"unchen



More information about the Comp.lang.c mailing list