Skip to content
Home » readability


The forgotten logical operators

Here’s something I notice in a lot of other people’s code I look at, which has always bothered me. This isn’t language-specific — I see it everywhere. Programmers create logical expressions with the boolean operators And, Or, and Not. It seems to require a sort of sideways view of things to apply the additional operators that work with boolean values, Eqv and Xor (or to use their non-bitwise counterparts which more people might recognize offhand, = and != (<> in LotusScript). This neglect often results in inefficient and hard-to-read logical expressions. For instance, suppose the code needs to test the assertion: “Either a and b are both 0, or neither is 0.” I often see such a test written as: If (a = 0 And b = 0) Or (a <> 0 And b <>… Read More »The forgotten logical operators