【问题标题】:Reload imported modules重新加载导入的模块
【发布时间】:2013-10-04 06:53:29
【问题描述】:

我面临的“问题”是,如果我使用 SWI-Prolog 模块系统,定义模块并在其他模块中使用它们,如果 imported 模块发生更改,SWI-Prolog 不会接受在加载 importing 模块时考虑。例如:

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

如果不使用consult,我应该如何强制Prolog查询所有导入的模块和它们导入的模块?

【问题讨论】:

    标签: module prolog swi-prolog prolog-toplevel


    【解决方案1】:

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

    【讨论】:

    • 最好澄清该快捷方式的意义所在。
    猜你喜欢
    • 2019-03-14
    • 2012-12-10
    • 2012-06-12
    • 2018-06-14
    • 2018-01-06
    • 1970-01-01
    • 2017-04-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多