It is essential to master these.
relational operators (<, >,
<=, >=) have a lower precedence to
arithmetic and are left associative. WARN:
i < j < k:= (i < j) < k where
(i < j) == 1 || 0; What you may want is
i < j && j < k
== and != have a lower precedence than
relational operators and are left associative.
! has the same precedence as unary plus and minus, and
is right associative. Logical operations && and
|| have lower precedence to than equality are left
associative.
Short-circuiting := if with the first operand we know
the outcome of the expression, then we do not compute the full
expression. e.g. (i != 0) && (j / i > 0) when
i is equal to zero the program knows that the expression
will fail and therefore not compute the second expression.
expr1 ? expr2 : expr3 :~ if expr1 then
expr2 else expr3
Allows us to execute multiple statements at once. for example in for_loop, in the first and third expressions It is left associative and has the lowest precedence of all operators. The first expression should have a side effect, otherwise is it pointless.
&:= the address of a variable in memory. Allows you
to assign the address of an lvalue to a pointer.
*:= the value of the variable at the address. The
pointer now becomes an alias for the variable. Also known as
dereferencing.
<< shifts the bits to the left. &
bitwise AND | bitwise inclusive OR ^ bitwise
XOR (exclusive OR) << left shift
>> right shift ~ bitwise NOT (ones’
complement) (unary)