Download Delphi BX Quick start manual
Transcript
Packages The requires clause The requires clause lists other, external packages that are used by the current package. It functions like the uses clause in a unit file. An external package listed in the requires clause is automatically linked at compile time into any application that uses both the current package and one of the units contained in the external package. If the unit files contained in a package make references to other packaged units, the other packages should be included in the first package’s requires clause. If the other packages are omitted from the requires clause, the compiler loads the referenced units from their .dcu (Windows and Linux) or .dpu (Linux) files. Avoiding circular package references Packages cannot contain circular references in their requires clauses. This means that • A package cannot reference itself in its own requires clause. • A chain of references must terminate without rereferencing any package in the chain. If package A requires package B, then package B cannot require package A; if package A requires package B and package B requires package C, then package C cannot require package A. Duplicate package references The compiler ignores duplicate references in a package’s requires clause. For programming clarity and readability, however, duplicate references should be removed. The contains clause The contains clause identifies the unit files to be bound into the package. Do not include file-name extensions in the contains clause. Avoiding redundant source code uses A package cannot be listed in the contains clause of another package or the uses clause of a unit. All units included directly in a package’s contains clause, or indirectly in the uses clauses of those units, are bound into the package at compile time. The units contained (directly or indirectly) in a package cannot be contained in any other packages referenced in requires clause of that package. A unit cannot be contained (directly or indirectly) in more than one package used by the same application. 9-12 Delphi Language Guide