user502187
user502187

Reputation:

Is there a way to use module/2 in ECLiPSe Prolog?

In SWI-Prolog, I am using code such as at the beginning of a module text file:

:- module(foo, [bar/2]).
:- use_module(library(jack)).

I don't want to change my code. How can I neverthelss use ECLiPSe Prolog (*). Is there some library that defines a module/2 directive in ECLiPSe Prolog?

Best Regards

(*) http://eclipseclp.org/

Upvotes: 1

Views: 449

Answers (4)

Paulo Moura
Paulo Moura

Reputation: 18663

SWI-Prolog (an others) module/2 directives can be replaced on ECLiPSe by module/1 + export/1 directives as you likely already found out. Also both SWI-Prolog and ECLiPSe support conditional compilation directives and the dialect flag. This should provide you with another alternative (not tested) for using the same Prolog files with both systems:

:- if(current_prolog_flag(dialect, swi)).

    :- module(foo, [p/1]).

:- elif(current_prolog_flag(dialect, eclipse)).

    :- module(foo).
    :- export(p/1).

:- else.

    ...

:- endif.

Upvotes: 0

jschimpf
jschimpf

Reputation: 5034

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]))
).

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.

Upvotes: 1

Paulo Moura
Paulo Moura

Reputation: 18663

You can compile Prolog module that uses SWI-Prolog module system using Logtalk for use with ECLiPSe (or any other of the supported Prolog compilers, including those that don't provide a module system).

Upvotes: 2

Sergii Dymchenko
Sergii Dymchenko

Reputation: 7209

No, there are only module/1 and module/3.

You an see the list of all what available here: http://eclipseclp.org/doc/bips/fullindex.html

Upvotes: 0

Related Questions