Expression Evaluation

From The Oxygene Language Wiki

Jump to:navigation, search

This is a Language topic
Feel free to add your notes to this topic below.



Order of Operations

Delphi Prism evaluates expressions from left to right for the same expression types and has the following order of precedence for operators:

Level
Operators
Description
1 @ () [] -> .  : Address off, Parenthesis, Array element access, Lambdas, and member access
2 not - (unary) + (unary) if case unary operations: not, minus and plus
3 * div / mod and shl shr as Multiplication, Division, Modulus, and, shift-left, shift-right and as casts.
4 + (binary) - (binary) or xor Addition, Subtraction, or and xor.
5 >= <= <> = > < Comparison Operators in is implies All the comparison operators including the Boolean Double Comparison, in, is and implies.
6 ^ Pointer Dereferencing
7 := += -= Assignment operators

All values are always evaluated (except in the case for booleans see Boolean Short-Circuit Evaluation below, and iif in which case only one of true or false is evaluated depending on the condition).


Boolean Short-Circuit Evaluation

For booleans there are two exceptions where the right side of an and and or expression isn't evaluated. For and this is when the left side of the expression is false, which case the right side doesn't matter anymore as the result is going to be false anyway. For or it's the other way around, if the left value is true the right side isn't evaluated and the result of the sub expression is true.


Nullable Types

See Nullable Types in Expressions for more information on the special rules for nullable types in expressions.


See Also


Oxygene-48.png

Area: Oxygene Language
Compiler version: Oxygene 5

Language GlossaryKeywordsTypesFAQHow To

Navigation
Areas
More
Toolbox