Free Pascal supports operator overloading. This means that it is possible to define the action of some operators on self-defined types, and thus allow the use of these types in mathematical expressions.
In addition, operator overloading can be used for some special actions that are strictly speaking not operators in the mathematical sense of the word. This is true for the procedures Inc and Dec (which are usable as a procedure only) and for implicit and explicit assignment (:= and typecasting). The enumerator operator (to define an enumerable series for a type) is also part of this class of operators.
Defining the action of an operator is much like the definition of a function or procedure, only there are some restrictions on the possible definitions, as will be shown in the subsequent.
Operator overloading is, in essence, a powerful notational tool; but it is also not more than that, since the same results can be obtained with regular function calls. When using operator overloading, it is important to keep in mind that some implicit rules may produce some unexpected results. This will be indicated.
There are 2 ways to declare operator overloads. The first way is the original way as implemented in Free Pascal, and is the most powerful. It is discussed in this chapter. There is also a second way, which can only be implemented for Advanced (or extended) records, it is discussed in the chapter on extended records.