TRUE and FALSE

Olumide O. Emuleomo olu at sysauto.UUCP
Thu Sep 6 07:39:35 AEST 1990


In article <2341 at cirrusl.UUCP>, dhesi%cirrusl at oliveb.ATC.olivetti.com (Rahul Dhesi) writes:
> I was brash enough to suggest
> 
> But in fact my suggested definitions are much more useful than the
> common recommendation of defining TRUE and FALSE.
> 
> No matter how careful the original programmer is, sooner or later
> somebody will come along and, noticing that TRUE means true, will try
> to do something like:
> 
>      i = isdigit(c);
>      ...
>      if (i == TRUE) ...
> 
> Of course, defining ONE and ZERO is fairly silly.  But defining TRUE
> and FALSE is quite risky.  I'll take fairly silly over quite risky any
> day.
> --
> Rahul Dhesi <dhesi%cirrusl at oliveb.ATC.olivetti.com>
> UUCP:  oliveb!cirrusl!dhesi

TRUE and FALSE were never meant to be tested explicitly.

Good programming practise demands that they be used somewhat as follows

if( keyword_found(fname) )
{
	etc...
	etc... etc..
}


keyword_found(char *fname_param)
{
	switch(foo)  
	{
	 case FAILURE:
		etc...
		return(FALSE);
	 case SQLNOTFOUND:
		more etc..
		return(FALSE);
	 	etc...
	}

	return(TRUE);
}

Cheers

--olu at sysauto.UUCP



More information about the Comp.lang.c mailing list