YAFL supports assertions, and the DEBUG control structure. Assertions are boolean expressions which must be evaluated to TRUE. Otherwise, the system is known to be unsafe.
METHOD Sqrt(r: REAL): REAL; BEGIN ASSERT r >= 0.0; ... END Sqrt;
Assertions are static conditions placed in the code by the programmer. In runtime, these assertions are checked, and the system halts with a comprehensive error message as soon as one of them cannot be evaluated to TRUE. By remaining in the source code over different successive versions, assertions significantly improve the sharpness of regression test plans as well as the overall quality of the resulting system.
A valuable side effect of assertions lies in their property of improving the readability of the source code. They provide the reader with some information regarding the conditions in which the code is supposed to work.
The DEBUG control structure includes a statement list which contains code, often related to validity checking. It is merely a generalization of the assertion mechanism.
YAFL provides a compile-time option called the DEBUG flag. If enabled, assertions as well as DEBUG statement lists are included in the resulting system. Otherwise, they are ignored. When the DEBUG flag is enabled, several panic conditions are catched by the runtime system: