next up previous index
Next: Arithmetic Evaluation Up: Module System Previous: Advanced Topics   Index

Subsections

Less Common Topics

Modules Using Other Languages

Modules created with the module/1 directive automatically import the module eclipse_language, which provides the standard set of ECLiPSe built-in predicates. To create a module that uses a different language dialect, use module/3. For instance

:- module(mystdcode, [], iso).
creates a module in which you can use ISO Standard Prolog7.5, but not all of ECLiPSe's usual language features. Note that the third argument (here iso) simply specifies a library which implements the desired language, so new languages can be added easily.

Creating and Erasing Modules at Runtime

A module can also be created explicitly by a running program with create_module/1 or create_module/3 and erased with erase_module/1. The latter should be used with care, erasing a module while a predicate defined in that module is being executed can provoke unpredictable results. The same holds for trying to erase essential system modules.


Locking Modules

By default, ECLiPSe does not strictly enforce the hiding of module internals. This facilitates program development as is makes it possible to inspect and trace without being too concerned about module boundaries. E.g. you can set a spy point on a local predicate p/3 in module othermod by calling:
:- spy(p/3)@othermod.
Once a module implementation is stable and there is a need for privacy, it is possible to lock a module. Locking makes it impossible to access internal, local items from outside the module. Of course, the module can still be used though its interface. The built-in predicates related to locking are lock/1 which provides a definitive lock, lock/2 which allows subsequent unlocking using a password ( unlock/2), and get_module_info/3 which allows to check whether a module is locked.


next up previous index
Next: Arithmetic Evaluation Up: Module System Previous: Advanced Topics   Index
Warwick Harvey
2004-08-07