Operator precedence
From REALbasicWiki
This text was originally written by Aaron Ballman on [his blog]:
In order from highest precedence to lowest:
. The dot operator AddressOf Delegate creation operator IsA Type checking operator ^ Exponentiation operator - Negation, the unary minus operator Not Logical not operator * / \ Mod Multiplication and division arithmetic operators - + Subtraction and addition arithmetic operators = > < >= <= <> Is Comparison operators And Bitwise and logical operator Or Xor Bitwise and logical operator : Pair creation operator
For the cases which have multiple operators in a single row, the precedence goes from left to right. So, for instance, multiplication is higher than floating-point division which is higher than integer division, which is higher than modulus. All operators are left-associative except for pairs (:) and exponentiation (^).
Left association means that (foo or bar or baz) will evaluate like ((foo or bar) or baz) instead of (foo or (bar or baz)). Conversely, right association means that (foo : bar : baz) will evaluate like (foo : (bar : baz)) instead of ((foo : bar) : baz).
So when you find yourself wondering why the following doesn't compile, you can consult the operator precedence table to understand it.
if not foo Is Nil then
The reason is because Not has higher precedence than Is, so it evaluates like if ((not foo) is nil). Obviously, not foo isn't valid unless foo can evaluate to a boolean or integer. And if it can evaluate to a boolean or an integer, Boolean/Integer Is Nil won't compile, so you'll get an error. Use parantheses to be explicit about the order you want the items to be evaluated.
