Quick start manual
9-10
Delphi Language Guide
Packages
Packages
A package is a specially compiled library used by applications, the IDE, or both.
Packages allow you to rearrange where code resides without affecting the source
code. This is sometimes referred to as application partitioning.
Runtime packages provide functionality when a user runs an application. Design-time
packages are used to install components in the IDE and to create special property
editors for custom components. A single package can function at both design time
and runtime, and design-time packages frequently work by referencing runtime
packages in their requires clauses.
To distinguish them from other libraries, packages are stored in files:
On Windows:
Package files end with the .bpl (Borland package library) extension.
On Linux:
Packages generally begin with the prefix bpl and have a .so extension.
Ordinarily, packages are loaded statically when an applications starts. But you can
use the LoadPackage and UnloadPackage routines (in the SysUtils unit) to load packages
dynamically.
Note
When an application utilizes packages, the name of each packaged unit still must
appear in the uses clause of any source file that references it. For more information
about packages, see the online Help.
Package declarations and source files
Each package is declared in a separate source file, which should be saved with the
.dpk extension to avoid confusion with other files containing Delphi code. A package
source file does not contain type, data, procedure, or function declarations. Instead, it
contains:
•a name for the package.
• a list of other packages required by the new package. These are packages to which
the new package is linked.
• a list of unit files contained by, or bound into, the package when it is compiled. The
package is essentially a wrapper for these source-code units, which provide the
functionality of the compiled package.
A package declaration has the form
package packageName;
requiresClause;
containsClause;
end.