Sign in Join
Wiki copytemporary

Uses: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-The `uses` clause of a Pascal module imports exported [[Identifier|identifiers]] from another module. It was introduced by [[UCSD Pascal]] and virtually every modern Pascal [[Compiler|compiler]], including [[FPC]], supports it, if no other mechanism is available.
1+The `uses` clause of a Pascal module imports exported [[Identifier|identifiers]] from another module. It was introduced by [[UCSD Pascal]] and virtually every modern Pascal [[Compiler|compiler]], including [[FPC]], supports it, if no other mechanism is available.
22
3-`Uses` is a [[Reserved word|reserved word]].
3+`Uses` is a [[Reserved word|reserved word]].
44
55## usage
66
77### location
88
9-Every Pascal module – i. e. [[Program|program]], `unit`, or `library` – can have at most one `uses` clause per section. It has to appear right after the section headings. Section headings are `interface` and `implementation` in a `unit`. A `program` does not have any explicit section headings, thus the `uses` clause appears immediately after the `program` header, but still after any [[global compiler directives]] as some may alter the `uses` clause.
9+Every Pascal module – i. e. [[Program|`program`]], `unit`, or `library` – can have at most one `uses` clause per section. It has to appear right after the section headings. Section headings are `interface` and `implementation` in a `unit`. A `program` does not have any explicit section headings, thus the `uses` clause appears immediately after the `program` header, but still after any [[global compiler directives]] as some may alter the `uses` clause.
1010
1111### syntax
1212
13-The `uses` clause consists of the word `uses`, followed by a [[Comma|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. Usually [[Unit|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. Example:
14-
15-``` pascal
13+The `uses` clause consists of the word `uses`, followed by a [[Comma|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. Usually [[Unit|`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. Example:
14+```
1615uses
17- math, sysUtils, baseUnix;
16+ math, sysUtils, baseUnix;
1817```
1918
20-Furthermore, each identifier may be followed by [[In|in]] and a string literal overriding the automatic lookup mechanism. The following will look for a `unit` named `foo` in the file `bar.pas`:
21-
22-``` pascal
19+Furthermore, each identifier may be followed by [[In|`in`]] and a string literal overriding the automatic lookup mechanism. The following will look for a unit named `foo` in the file `bar.pas`:
20+```
2321uses
24- foo in 'bar.pas';
22+ foo in 'bar.pas';
2523```
2624
2725### access and shadowing
2826
29-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. For instance, [`math.ceil`](https://www.freepascal.org/docs-html/rtl/math/ceil.html) as well as just `ceil` refer to the same function (unless in the current module `ceil` has been defined otherwise).
27+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. For instance, [`math.ceil`](<https://www.freepascal.org/docs-html/rtl/math/ceil.html>) as well as just `ceil` refer to the same function (unless in the current module `ceil` has been defined otherwise).
3028
31-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 be accessed via fully-qualified identifiers. A [[With|with-clause]] may alleviate this situation.
29+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 be accessed via fully-qualified identifiers. A [[With|`with`-clause]] may alleviate this situation.
3230
3331### loading and unloading
3432
35-At program start, all [[Initialization|initialization]] statement blocks, if any, are processed in the order the units were listed in – possibly recursively. At program termination, all [[Finalization|finalization]] are processed *in the reverse order*.
33+At program start, all [[Initialization|`initialization`]] statement blocks, if any, are processed in the order the units were listed in – possibly recursively. At program termination, all [[Finalization|`finalization`]] are processed _in the reverse order_.
3634
37-If initialization fails, only units that have been initialized so far are finalized. The main block of a program is not executed at all. Confer also [FPC issue 0036754](https://gitlab.com/freepascal.org/fpc/source/-/issues/0036754).
35+If initialization fails, only units that have been initialized so far are finalized. The main block of a program is not executed at all. Confer also [FPC issue 0036754](<https://gitlab.com/freepascal.org/fpc/source/-/issues/0036754>).
3836
3937### special units
4038
41-In FPC the [[System unit|unit system]] is implicitly included by every program. It is wrong to explicitly list it in the `uses` clause. 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.
39+In FPC the [[System unit|unit `system`]] is implicitly included by every program. It is wrong to explicitly list it in the `uses` clause. 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.
4240
4341## see also
4442
45-- [[Namespaces|namespaces]]
46-- [§ “Unit dependencies” in the *Free Pascal reference guide*](https://www.freepascal.org/docs-html/ref/refse114.html)
43+ * [[Namespaces|namespaces]]
44+ * [§ About "in" keyword of the "uses" section in the _Free Pascal reference guide_](<https://www.freepascal.org/docs-html/ref/refse111.html>)
45+ * [§ “Unit dependencies” in the _Free Pascal reference guide_](<https://www.freepascal.org/docs-html/ref/refse114.html>)
4746
4847---
49-*From the Free Pascal wiki, page "Uses", as it stood on 2022-01-28 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
48+*From the Free Pascal wiki, page "Uses", as the Internet Archive kept it on 2026-01-27, last changed on 2024-07-13. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history