The current structure of the module system has been designed with
some specific organisations for large programs in mind. Many large
programs define a basic library layer on top of which the actual program
itself is defined. The module user
, acting as the default
module for all other modules of the program can be used to distribute
these definitions over all program module without introducing the need
to import this common layer each time explicitly. It can also be used to
redefine built-in predicates if this is required to maintain
compatibility to some other Prolog implementation. Typically, the
loadfile of a large application looks like this:
The `use_module' declarations will import the public predicates from
the generic modules into the user
module. The
`ensure_loaded' directive loads the modules that constitute the actual
application. It is assumed these modules import predicates from each
other using
use_module/[1,2]
as far as necessary.
In combination with the object-oriented schema described below it is possible to define a neat modular architecture. The generic code defines general utilities and the message passing predicates (invoke/3 in the example below). The application modules define classes that communicate using the message passing predicates.