Operator precedence
dBL applies strict rules of precedence to compound expressions. In expressions that contain multiple operations, parenthetical groupings are evaluated first, with nested groupings evaluated from the "innermost" grouping outward. After all parenthetical groupings are evaluated, the rest of the expression is evaluated according to the following operator precedence:
Order of precedence (highest to lowest) |
Operator description or category |
& |
Macro |
(expression) |
Parenthetical grouping, all expressions |
-> |
Alias |
( ) [] . NEW :: |
Object operators: call; member (square bracket or dot); new; scope resolution |
+ ++ |
Unary plus/minus, increment/decrement |
^ ** |
Exponentiation |
* / % |
Multiply, divide, modulus |
+ |
Addition, subtraction |
= == <> # < <= > >= $ |
Comparison |
NOT |
Logical Not |
AND |
Logical And |
OR |
Logical Or |
= := += = *= /= %= |
Assignment |
In compound expressions that contain operators from the same precedence level, evaluation is conducted on a literal left-to-right basis. For example, no operator precedence is applied in the expressions 21/7*3 and 3*21/7 (both return 9).
Heres another example:
4+5*(6+2*(8-4)-9)%19>=11
This example is evaluated in the following order:
84=4
2*4=8
6+8=14
14-9=5
5*5=25
25%19=6
4+6=10
The result is the logical value false.