Chapter 7. Operators
This chapter describes the symbolic operators, their precedence and semantics. Chapter 5, describes the named operators in depth, but not the symbolic operators, because it’s hard to alphabetize symbols. This chapter describes the symbolic operators in depth.
Delphi defines the following operators. Each line lists the operators with the same precedence; operator precedence is highest at the start of the list and lowest at the bottom:
@ not ^ + - (unary operators) |
* / div mod and shl shr as
|
+ - or xor
|
> < >= <= <> = in is
|
A Variant can be a string, number, Boolean, or
other value. If an expression mixes Variant and
non-Variant operands, Delphi converts all operands
to Variant. If the Variant
types do not match, Delphi casts one or both operands as needed for
the operation, and produces a Variant result. See
the Variant type in Chapter 5
for more information about Variant type
casts.
Unary Operators
-
@operator Returns the address of its operand. The address of a variable or ordinary subroutine is a
Pointer, or if the$Tor$TypedAddresscompiler directive is used, a typed pointer (e.g.,PInteger).The address of a method has two parts: a code pointer and a data pointer, so you can assign a method address only to a variable of the appropriate type, and not to a generic
Pointervariable. If you take the address of a method using a class reference instead of an object reference, the@operator returns just the code pointer. For example:
Ptr := @TObject.Free;
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access