SWI Prolog sure_loaded错误 [英] SWI Prolog ensure_loaded error

查看:141
本文介绍了SWI Prolog sure_loaded错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SWI Prolog编写一本数学逻辑书,该书提供了Prolog中某些算法的源代码.问题是,当我尝试加载文件时,解释器仅提示类似以下内容:

I am using SWI Prolog for a mathematical logic book and the book provided source code for some of the algorithms in Prolog. The problem is that when I try to load a file, the interpreter just prompt something like:

load_files/2: No permission to load source `**' (Non-module file already loaded into module **; trying to load into io)

我查看了源代码,发现大多数文件都以:

I looked into the source code and found that most of the files start with:

:- module(**,[***]).

之后

user:file_search_path(common,'../common').
:- ensure_loaded(ops).
:- ensure_loaded(def).

,似乎对同一个文件调用了sure_loaded两次会导致错误,并且如果已经加载的文件中的某些谓词(例如ops.pl)不会在尝试为其加载文件的文件中定义第二次.

and it seems that calling ensure_loaded twice with the same file caused the error, and if some of the predicates in the already loaded file (ops.pl for example) will not be defined in the file that tried to load it for the second time.

我尝试将sure_loaded更改为use_module并进行咨询,但是没有用.

I tried changing ensure_loaded to use_module and consult but didn't work.

推荐答案

我通过将所有suresure_loaded移动到一个文件来解决了这个问题.

I solved the problem by moving all the ensure_loaded to one file.

这篇关于SWI Prolog sure_loaded错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆