xsb "No procedure usermod" 当谓词已经定义时
xsb "No procedure usermod" when predicate is already defined
所以在我的文件中有
:- use_module(standard, datime/1).
today(Y, M, D) :-
datime(datime(Y, M, D, _, _, _).
运行 这个直接在命令行给出
XSB Version 3.6. (Gazpatcho) of April 22, 2015
[x86-pc-windows; mode: optimal; engine: slg-wam; scheduling: local]
[Build date: 2015-04-22]
| ?- use_module(standard, datime/1).
yes
| ?- datime(datime(Y, M, D, _, _, _)).
Y = 2016
M = 5
D = 17
yes
但是加载文件本身和运行函数给出了一个错误
| ?- [utils].
[Compiling .\utils]
[utils compiled, cpu time used: 0.0780 seconds]
[utils loaded]
yes
| ?- today(Y, M, D).
++Error[XSB/Runtime/P]: [Existence (No procedure usermod : today / 3 exists)] []
Forward Continuation...
... machine:xsb_backtrace/1 From C:\Program Files (x86)\XSB\syslib\machine.xwam
... loader:load_pred1/1 From C:\Program Files (x86)\XSB\syslib\loader.xwam
... loader:load_pred0/1 From C:\Program Files (x86)\XSB\syslib\loader.xwam
... loader:load_pred/1 From C:\Program Files (x86)\XSB\syslib\loader.xwam
... x_interp:_$call/1 From C:\Program Files (x86)\XSB\syslib\x_interp.xwam
... x_interp:call_query/1 From C:\Program Files (x86)\XSB\syslib\x_interp.xwam
... standard:call/1 From C:\Program Files (x86)\XSB\syslib\standard.xwam
... standard:catch/3 From C:\Program Files (x86)\XSB\syslib\standard.xwam
... x_interp:interpreter/0 From C:\Program Files (x86)\XSB\syslib\x_interp.xwam
... loader:ll_code_call/3 From C:\Program Files (x86)\XSB\syslib\loader.xwam
... standard:call/1 From C:\Program Files (x86)\XSB\syslib\standard.xwam
... standard:catch/3 From C:\Program Files (x86)\XSB\syslib\standard.xwam
知道为什么会这样以及如何解决这个问题吗?文件中的其他谓词也会发生这种情况。
您的代码有 3 个问题:
- 您的
today/3
声明缺少结尾 )
、
today/3
未导出
use_module/2
需要一个符号列表作为第二个参数,或者使用 import sym from mod
.
如果您将 utils.P
文件定义如下
:- import datime/1 from standard.
:- export today/3.
today(Y, M, D) :- datime(datime(Y, M, D, _, _, _)).
您可以通过以下任一方式使用它:
直接导入谓词:
| ?- import today/3 from utils.
yes
| ?- today(Y,M,D).
Y = 2016
M = 5
D = 18
使用限定名称使用 :
| ?- utils:today(Y,M,D).
Y = 2016
M = 5
D = 18
直接加载模块
| ?- [utils].
[utils loaded]
| ?- today(Y,M,D).
Y = 2016
M = 5
D = 18
所以在我的文件中有
:- use_module(standard, datime/1).
today(Y, M, D) :-
datime(datime(Y, M, D, _, _, _).
运行 这个直接在命令行给出
XSB Version 3.6. (Gazpatcho) of April 22, 2015
[x86-pc-windows; mode: optimal; engine: slg-wam; scheduling: local]
[Build date: 2015-04-22]
| ?- use_module(standard, datime/1).
yes
| ?- datime(datime(Y, M, D, _, _, _)).
Y = 2016
M = 5
D = 17
yes
但是加载文件本身和运行函数给出了一个错误
| ?- [utils].
[Compiling .\utils]
[utils compiled, cpu time used: 0.0780 seconds]
[utils loaded]
yes
| ?- today(Y, M, D).
++Error[XSB/Runtime/P]: [Existence (No procedure usermod : today / 3 exists)] []
Forward Continuation...
... machine:xsb_backtrace/1 From C:\Program Files (x86)\XSB\syslib\machine.xwam
... loader:load_pred1/1 From C:\Program Files (x86)\XSB\syslib\loader.xwam
... loader:load_pred0/1 From C:\Program Files (x86)\XSB\syslib\loader.xwam
... loader:load_pred/1 From C:\Program Files (x86)\XSB\syslib\loader.xwam
... x_interp:_$call/1 From C:\Program Files (x86)\XSB\syslib\x_interp.xwam
... x_interp:call_query/1 From C:\Program Files (x86)\XSB\syslib\x_interp.xwam
... standard:call/1 From C:\Program Files (x86)\XSB\syslib\standard.xwam
... standard:catch/3 From C:\Program Files (x86)\XSB\syslib\standard.xwam
... x_interp:interpreter/0 From C:\Program Files (x86)\XSB\syslib\x_interp.xwam
... loader:ll_code_call/3 From C:\Program Files (x86)\XSB\syslib\loader.xwam
... standard:call/1 From C:\Program Files (x86)\XSB\syslib\standard.xwam
... standard:catch/3 From C:\Program Files (x86)\XSB\syslib\standard.xwam
知道为什么会这样以及如何解决这个问题吗?文件中的其他谓词也会发生这种情况。
您的代码有 3 个问题:
- 您的
today/3
声明缺少结尾)
、 today/3
未导出use_module/2
需要一个符号列表作为第二个参数,或者使用import sym from mod
.
如果您将 utils.P
文件定义如下
:- import datime/1 from standard.
:- export today/3.
today(Y, M, D) :- datime(datime(Y, M, D, _, _, _)).
您可以通过以下任一方式使用它:
直接导入谓词:
| ?- import today/3 from utils.
yes
| ?- today(Y,M,D).
Y = 2016
M = 5
D = 18
使用限定名称使用 :
| ?- utils:today(Y,M,D).
Y = 2016
M = 5
D = 18
直接加载模块
| ?- [utils].
[utils loaded]
| ?- today(Y,M,D).
Y = 2016
M = 5
D = 18