RE: [R] if(foo == TRUE) .. etc

From: bogdan romocea <>
Date: Sat 23 Apr 2005 - 03:26:33 EST

Great suggestion; it made me change all my Ts/Fs to TRUE/FALSE. Given

   F <- TRUE
   T <- FALSE
is it possible to forbid T to stand for TRUE, and F for FALSE in

Or, alternatively, never allow F <- whatever and T <- whatever?

I don't know what the technical side is, but I think it would be much better if this particular blunder (major, yet rather easy to overlook) was impossible to make.

-----Original Message-----
From: Martin Maechler [] Sent: Wednesday, April 20, 2005 8:31 AM
Subject: [R] if(foo == TRUE) .. etc

>>>>> "Andy" == Andy Bunn <>
>>>>> on Tue, 19 Apr 2005 10:27:04 -0400 writes:

    Andy> is.tuesday <- as.POSIXlt(Sys.time())$wday == 2     Andy> if (is.tuesday == T) { ....}

aaah, this really hurts my eyes or rather the brain behind! And it's by far not the first such instance...

Rather use " if (is.tuesday) { .... } "

More generally, please, please, everyone :


		if (something == TRUE)
	with    if (something)
		if (something.or.other == FALSE)
	with    if (!something.or.other)

{and even more for cases where you have  'T' and 'F' instead of 'TRUE' and 'FALSE' -  which is against all recommendations, since   F <- TRUE
  T <- FALSE
 are valid statements, probably not common, but think what  happens when you accidentally have the equivalent of "T <- 0"  somewhere in your global enviroment!

Martin Maechler, ETH Zurich mailing list PLEASE do read the posting guide! mailing list PLEASE do read the posting guide! Received on Sat Apr 23 03:31:14 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:22 EST