Question

The "problem" I am facing is that if I use the SWI-Prolog module system, defining modules and using them in other modules, if an imported module changes SWI-Prolog does not take it in consideration when loading the importing module. For example:

% file topmod.pl
:- module(topmod, [thetop/0]).

:- use_module(bottommod).

thetop :-
    thebottom(S),
    format('This is the top~nAnd this is ~w~n', [S]).

% file bottommod.pl
:- module(bottommod, [thebottom/1]).

thebottom('the bottom').

If I now load them:

?- [thetop].
%  bottommod compiled into bottommod 0.00 sec, 2 clauses
% topmod compiled into topmod 0.00 sec, 6 clauses
true.

?- thetop.
This is the top
And this is the bottom
true.

If I now change the file:

% file bottommod.pl changes

- thebottom('the bottom').
+ thebottom('the foobar').

?- [thetop].
% topmod compiled into topmod 0.00 sec, 1 clauses
true.

?- thetop.
This is the top
And this is the bottom
true.

?- module(bottommod).
true.

?- listing.
thebottom('the bottom').
true.

How should I force Prolog to consult all the imported modules and the modules they import, short of using consult?

Was it helpful?

Solution

You can use SWI-Prolog make/0 predicate to reload all modified source files since last loaded.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top