uses clause of a Pascal module imports exported identifiers from another module.
It was introduced by UCSD Pascal and virtually every modern Pascal compiler, including FPC, supports it, if no other mechanism is available.
Uses is a reserved word.
uses clause consists of the word
uses, followed by a comma-separated list of module names, which is terminated by a semicolon.
The modules listed in the clause have to be capable of exporting identifiers, that means a
program name may not appear in the list.
unit names are listed in the clause.
The module name of the module, that is about to be defined, can not appear in the list.
uses math, sysUtils, baseUnix;
access and shadowing
This makes identifiers exported by the listed modules, for units that means identifiers declared in the
interface section, known in the current module.
Either the fully-qualified identifier which is prefixed by the module name, and just the identifier’s stem can be used to refer to the same identifier.
math.ceil as well as just
ceil refer to the same function.
However, two or more units listed in the
uses clause might declare the same identifier.
Then, only the identifier declared by the unit later in the list can be referred to using the short notation.
Identifiers declared by earlier units in the
uses clause can only accessed be via fully-qualified identifiers.
with-clause may alleviate this situation.
At program start, all
initialization statement blocks, if any, are processed in the order the units were listed in – possibly recursively.
At program termination, all
finalization are processed in the reverse order.
If initialization fails, only units that have been initialized so far are finalized. The main block of a program is not executed at all.
In FPC the unit
system is implicitly included by every program.
It is wrong to explicitly list it in the
Inclusion of the
system unit can be disabled by using the
-Us compiler switch.
This switch indicates/ought to indicate, that a/the system unit is about to be compiled.