Originale-mail to me for new edition

 

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) 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.

 

Topic groups

 

See also

Package declarations and source files

The contains clause

 

 

译文

 

requires子句

 

requires子句列出了用于当前包的其他外部包。其作用相当于单元文件中的uses子句。列于requires子句中的外部包自动在编译时被连接到任何应用程序中,前提是该应用程序既使用了当前包,又使用了包含在外部包中的某个单元。

如果包含在包中的单元文件引用了其他包的单元,那么其他的包应被包括在第一个包的requires子句中。如果没有被包括,那么编译器将从相应的.dcuWindows)或.dpuLinux)文件中加载被引用的单元。

 

避免包引用循环

包的requires子句中不能包含循环引用。即:

·    包不能通过其自身的requires子句对其自身进行引用

·    包的引用链必须以一个没有引用任何其他包的包结束。如果包A请求包B,那么包B不能请求包A;如果包A请求包B并且包B请求包C,那么包C不能请求包A

 

包引用重复

编译器忽略在包的requires子句中出现的重复引用。但为了使代码清楚易读,应删除重复引用。

 

主题组

 

相关主题

包声明和源文件

contains子句