问题描述
在SWI-Prolog中,我正在使用诸如开头的代码模块文本文件:
In SWI-Prolog, I am using code such as at the beginningof a module text file:
:- module(foo, [bar/2]).
:- use_module(library(jack)).
我不想更改我的代码.我怎么能没用ECLiPSe序言(*).是否有一些库定义了ECLiPSe Prolog中的module/2
指令?
I don't want to change my code. How can I neverthelss useECLiPSe Prolog (*). Is there some library that defines amodule/2
directive in ECLiPSe Prolog?
最好的问候
推荐答案
以下代码定义了一个宏,该宏将module/2映射为module/3指令:
The following code defines a macro that maps module/2 into module/3 directives:
:- export macro((:-)/1, translate_directive/2, [top_only]).
translate_directive(
(:- module(Module, Exports)),
(:- module(Module, Exports, [swi]))
).
在编译为SWI编写的模块之前编译(或导入)此文件.请注意,模块/3的第三个参数必须包含一个语言模块,与您的模块所写的方言相对应.我在这里使用了swi
,其他选择是quintus
,或ECLiPSe的本机eclipse_language
.
Compile (or import) this before compiling the module written for SWI. Note that the 3rd argument of module/3 must contain a language module, corresponding to the dialect your module is written in. I have used swi
here, other choices would be quintus
, iso
or ECLiPSe's native eclipse_language
.
这篇关于有没有办法在ECLiPSe Prolog中使用module/2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!