Quick start manual
3-4
Delphi Language Guide
Unit structure and syntax
Unit names must be unique within a project. Even if their unit files are in different
directories, two units with the same name cannot be used in a single program.
The interface section
The interface section of a unit begins with the reserved word interface and continues
until the beginning of the implementation section. The interface section declares
constants, types, variables, procedures, and functions that are available to clients—
that is, to other units or programs that wish to use elements from this interface
section. These entities are called public because a client can access them as if they
were declared in the client itself.
The interface declaration of a procedure or function includes only the routine’s
heading. The block of the procedure or function follows in the implementation
section. Thus procedure and function declarations in the interface section work like
forward declarations, although the forward directive isn’t used.
The interface declaration for a class must include declarations for all class members.
The interface section can include its own uses clause, which must appear
immediately after the word interface. For information about the uses clause, see
“Unit references and the uses clause” on page 3-5.
The implementation section
The implementation section of a unit begins with the reserved word implementation
and continues until the beginning of the initialization section or, if there is no
initialization section, until the end of the unit. The implementation section defines
procedures and functions that are declared in the interface section. Within the
implementation section, these procedures and functions may be defined and called in
any order. You can omit parameter lists from public procedure and function
headings when you define them in the implementation section; but if you include a
parameter list, it must match the declaration in the interface section exactly.
In addition to definitions of public procedures and functions, the implementation
section can declare constants, types (including classes), variables, procedures, and
functions that are private to the unit—that is, inaccessible to clients.
The implementation section can include its own uses clause, which must appear
immediately after the word implementation. For information about the uses clause,
see “Unit references and the uses clause” on page 3-5.
The initialization section
The initialization section is optional. It begins with the reserved word initialization
and continues until the beginning of the finalization section or, if there is no
finalization section, until the end of the unit. The initialization section contains
statements that are executed, in the order in which they appear, on program start-up.