C Style (Was Re: == vs =)

David Goodenough dg at lakart.UUCP
Fri Apr 29 02:35:42 AEST 1988


>From article <175 at obie.UUCP>, by wes at obie.UUCP (Barnacle Wes):
> In article <255 at oink.UUCP>, jep at oink.UUCP (James E. Prior) writes:
>>    if (var==TRUE)
>> 
>> is not only abominable, it can be dangerous.  var==TRUE tends to presume
>> that the only valid values of var are FALSE and TRUE.
> 
> Right.  The only really safe way to do this is:
 
[safe and silly way deleted]

Why can no one see the forest because of all the trees getting in the way?

	if (var != FALSE)

will *_ALWAYS_* work NO MATTER WHAT, and it satisfies those that need to test
their booleans in a strange manner.

	if (var)

is what I use when testing a boolean, and if it's an integer then I say

	if (var != 0)

which is what I usually mean.
--
	dg at lakart.UUCP - David Goodenough		+---+
							| +-+-+
	....... !harvard!adelie!cfisun!lakart!dg	+-+-+ |
						  	  +---+



More information about the Comp.lang.c mailing list