Quick start manual

4-14
Delphi Language Guide
Expressions
Without parentheses, however, the compiler follows operator precedence rules and
reads it as
(X = (Y or X)) = Z
which results in a compilation error unless Z is Boolean.
Parentheses often make code easier to write and to read, even when they are, strictly
speaking, superfluous. Thus the first example could be written as
X + (Y * Z)
Here the parentheses are unnecessary (to the compiler), but they spare both
programmer and reader from having to think about operator precedence.
Function calls
Because functions return a value, function calls are expressions. For example, if
you’ve defined a function called Calc that takes two integer arguments and returns an
integer, then the function call Calc(24, 47) is an integer expression. If I and J are
integer variables, then I + Calc(J, 8) is also an integer expression. Examples of
function calls include
Sum(A, 63)
Maximum(147, J)
Sin(X + Y)
Eof(F)
Volume(Radius, Height)
GetValue
TSomeObject.SomeMethod(I,J);
For more information about functions, see Chapter 6, “Procedures and functions”.
Set constructors
A set constructor denotes a set-type value. For example,
[5, 6, 7, 8]
denotes the set whose members are 5, 6, 7, and 8. The set constructor
[ 5..8 ]
could also denote the same set.
The syntax for a set constructor is
[ item
1
, ..., item
n
]
where each item is either an expression denoting an ordinal of the set’s base type or a
pair of such expressions with two dots (..) in between. When an item has the form x..y,
it is shorthand for all the ordinals in the range from x to y, including y; but if x is
greater than y, then x..y, the set [x..y], denotes nothing and is the empty set. The set
constructor [ ] denotes the empty set, while [x] denotes the set whose only member
is the value of x.