Priority in expression
List of the priority levels in the expression of the Cind language:
priority level |
operator or statement |
selecting from |
I |
brackets (...) that separates independent expression
or vector, unless it is a type cast operator |
left |
II |
instructions with own statement, e.g. block { ... }, if, enter, etc.,
preservation operator: $x,
and expressions with type operators.
|
left |
III |
-x (unary negation) applied to numbers and expressions
only at the beginning or when the preceding element is an another operator |
right |
IV |
messages: x.msg, x.[msg],
properties: x:y, x:[y],
element operator: x[y],
function execution: x(y,..) but only with a vector or expression in brackets (...)
|
left |
V |
x++, x-- |
left |
VI |
++x, --x, -x, !x, ~x,
type cast operator: (type)x,
and the rest cases of the function execution: f v |
right |
VII |
& (bitwise and) |
left |
VIII |
^ (bitwise xor) |
left |
IX |
| (bitwise or) |
left |
X |
*, /, % (multiplication, division, modulo) |
left |
XI |
+, - (addition, subtraction) |
left |
XII |
<<, >> (bitwise left and right shift) |
left |
XIII |
<, <=, >, >= (less than or greater than or equal to) |
left |
XIV |
==, != (equal to or not equal to) |
left |
XV |
&& (logical and) |
left |
XVI |
|| (logical or) |
left |
XVII |
x?y:z (ternary conditional) |
left |
XVIII |
-> (functional operator) |
left |
XIX |
%%, -% (function composition) |
left |
XX |
=,
+=,
-=,
*=,
/=,
%=,
&=,
^=,
|=,
<<=,
>>=
(assignment operators) |
right |
Column "selecting from" says if the expression statement is interpreted
from left-to-right or from right-to-left.
Examples:
2 + 2 * 2 // 6
2 / 2 * 2 // 2
2 + - 1 // 2 + (-1)
x & y == z // (x & y) == z
x = y = z // x = (y = z)
x ++ y // (x++)(y)
x ++ ++ y // ((x++)++)(y)
++ x -- // ++(x--)
x -> x + 1 // fun(x) { return x+1; }
|
|