重新加载已导入的模块。

3

我面临的“问题”是,如果我使用SWI-Prolog模块系统,定义模块并在其他模块中使用它们,如果一个导入的模块改变了SWI-Prolog,则在加载导入模块时SWI-Prolog不会考虑这一点。例如:

% 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').

如果我现在加载它们:

?- [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.

如果我现在更改文件:
% 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.

如何强制Prolog查询所有已导入的模块以及它们所导入的模块,除了使用consult之外?

1个回答

9
你可以使用SWI-Prolog的make/0谓词来重新加载自上次加载以来修改的所有源文件。

3
最好澄清那个快捷方式何时有意义。 - Paulo Moura

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接