next up previous
Next: Foreign Language Interface Up: Using Modules Previous: Module Handling Predicates

Compatibility of the Module System

The principles behind the module system of SWI-Prolog differ in a number of aspects from the Quintus Prolog module system.

The meta_predicate/1 declaration causes the compiler to tag arguments that pass module sensitive information with the module using the :/2 operator. This approach has some disadvantages:

Unfortunately the transparent predicate approach also has some disadvantages. If a predicate A passes module sensitive information to a predicate B, passing the same information to a module sensitive system predicate both A and B should be declared transparent. Using the Quintus approach only A needs to be treated special (i.e. declared with meta_predicate/1) gif. A second problem arises if the body of a transparent predicate uses module sensitive predicates for which it wants to refer to its own module. Suppose we want to define findall/3 using assert/1 and retract/1 gif. The example in figure gif gives the solution.

  
Figure: findall using modules

The Quintus meta_predicate/1 directive can in many cases be replaced by the transparent declaration. Figure gif gives a definition of meta_predicate/1 as available from the `quintus' library package.

  
Figure: Definition of meta_predicate/1

The discussion above about the problems with the transparent mechanism



next up previous
Next: Foreign Language Interface Up: Using Modules Previous: Module Handling Predicates



Passani Luca
Tue Nov 14 08:58:33 MET 1995