Originale-mail to me for new edition

 

The finalization section

 

The finalization section is optional and can appear only in units that have an initialization section. The finalization section begins with the reserved word finalization and continues until the end of the unit. It contains statements that are executed when the main program terminates. Use the finalization section to free resources that are allocated in the initialization section.

Finalization sections are executed in the opposite order from initializations. For example, if your application initializes units A, B, and C, in that order, it will finalize them in the order C, B, and A.

Once a unit’s initialization code starts to execute, the corresponding finalization section is guaranteed to execute when the application shuts down. The finalization section must therefore be able to handle incompletely initialized data, since, if a runtime error occurs, the initialization code might not execute completely.

 

Topic groups

Programs and units: Overview

Program structure and syntax: Overview

The program heading

The program uses clause

The block

Unit structure and syntax: Overview

The unit heading

The interface section

The implementation section

The initialization section

The finalization section

Unit references and the uses clause

The syntax of a uses clause

Multiple and indirect unit references

Circular unit references

 

See also

The implementation section

The initialization section

The interface section

The unit heading

Unit structure and syntax: Overview

 

 

译文

 

结束节

 

结束节是可选的,当且仅当单元中有初始化节时才允许有结束节。结束节以保留字finalization开始,直到单元结束。当主程序终止时,结束节中的语句被执行。在初始化节中分配的资源,通常在结束节中释放。

对于项目中的多个单元,结束节执行的顺序与初始化节执行的顺序相反。例如,如果在应用程序启动时按照单元ABC的顺序进行初始化,那么在应用程序结束时将按照单元CBA的顺序执行相应的结束节。

一旦单元初始化节的代码开始执行,则相应的结束节将在应用程序结束时保证被执行。所以结束节必需能完全处理初始化过的数据,因为当运行时错误发生时,初始化节代码可能没有完全执行。

 

主题组

程序和单元:概述

程序结构和语法:概述

程序首部

程序的uses子句

单元结构和语法:概述

单元首部

接口节

实现节

初始化节

结束节

单元引用和uses子句

uses子句的语法

多重和间接单元应用

循环单元引用

 

相关主题

实现节

初始化节

接口节

单元首部

单元结构和语法:概述

 

编者注

结束节中的语句在程序结束时执行一次,程序运行中不执行。运行中,其它语句也无法将执行点跳转到结束节中。