TRUE and FALSE

M.T.Russell mtr at ukc.ac.uk
Wed Sep 5 21:21:06 AEST 1990


In article <3686 at goanna.cs.rmit.oz.au> ok at goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
>I have seen too many Pascal programs where people wrote
>	x: boolean; ... if x = TRUE then ...
> ... I _have_ seen it in C code, and it was wrong.

I don't want people who do that kind of thing hacking my code.
If they get something as simple as this wrong then what hope is
there of them getting anything else right?

>Why should your proposed C variant be more restrictive than Pascal?
>In Pascal FALSE < TRUE is allowed, meaningful, and true.

I can't see any use for this, but I don't have any violent objection
to it.

I'd make a couple of changes to my scheme on reflection: I'd disallow
assignment of 0 and 1 to bool variables, and make TRUE and FALSE keywords.
I'd also turn on a macro __BOOL__ to indicate that the extension was
there, so that applications could say:

	#ifndef __BOOL__
	typedef int bool;
	#define TRUE 1
	#define FALSE 0
	#endif

Mark



More information about the Comp.lang.c mailing list