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.
Program structure and syntax:
Overview
Unit structure and syntax: Overview
Unit references and
the uses clause
Multiple and indirect unit
references
Unit structure and syntax: Overview
在单元中,以保留字implementation开始,直到初始化节开始(如果初始化节存在,但不含保留字initialization)或直到单元结束,这之间的部分是实现节。在接口节中声明的过程和函数,都在实现节中定义。在实现节中,可以对这些过程和函数以任意的顺序定义和调用。此外,对这些在接口中声明的公共过程和函数,在实现节中定义时可以省略参数列表;但如果在定义时要包括参数列表,则必需与接口节中的声明严格匹配。
除了定义公共过程和函数以外,实现节还可以声明常量、类型(包括类)、变量、过程和函数等,这些实体仅限于在当前单元的实现节中使用,因此叫做私有(private)实体,也就是说,这些实体对于单元的客户是不可见的。
实现节可以包括其自身的uses子句,但必需紧随保留字implementation之后出现。关于uses子句的更多信息,见单元引用和uses子句。