next up previous index
Next: Compiler Modes Up: The Compiler Previous: Program Source

Procedure Types

Procedures can be static and dynamic and this feature can be queried with the stability flag of get_flag/3.

Static procedures are compiled as one unit, they are thus executed more efficiently, and they can be modified only by replacing them by another procedure. By contrast, dynamic procedures are compiled clause-wise, they are executed slightly less efficiently, but their source form can also be retrieved, and they can be modified by adding or removing single clauses or clause sequences.

By default all procedures are static, dynamic procedures must be declared by the dynamic/1 declaration, except that undefined procedures for which assert/1,2 is called are silently declared as dynamic by the event handler, and so no declaration is needed.

When compiling static procedures, the compiler remembers their position in the file, which can be then queried by get_flag/3. The library scattered actually uses this feature to retrieve predicates whose clauses are not consecutive.



Micha Meier
Mon Mar 4 12:11:45 MET 1996