3

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?

4

1 回答 1

8

您可以使用 SWI-Prologmake/0谓词重新加载自上次加载以来所有修改过的源文件。

于 2013-10-04T11:17:20.707 回答