Re: [eclipse-users] Predicate declarations in Eclipse

From: Joachim Schimpf (Independent Contractor) <"Joachim>
Date: Mon, 30 Apr 2007 17:07:57 +0100
Siddharth Angrish wrote:
> Hi
>         I am trying to port a big prolog code (FSA6) to ECLiPse. The
> code is compatible
> with swi/sicstus/yap(SSY) prologs. I have a few queries regarding
> predicate delarations:
> 1) SSY support the keyword, multifile. Does EClipSe use "dynamic" for
> the purpose?

Yes, the conmpatibility packages currently define multifile as dynamic.

> 2) Does "dynamic" also serve the purpose of the keyword
> "discontiguous" which is there
> in all SSY

Well, Eclipse supports discontigous, but doesn't recognize the
module: prefix.  So you may be better off redefining it as dynamic
for your purposes.  Add the following to the compatibility package
you are using:

:- export discontiguous/1.
:- export op(1150, fx, (discontiguous)).
:- tools(discontiguous/1,discontiguous_/2).
discontiguous_(Pred, Module) :-

and add discontiguous/1 to the existing directive
:- export eclipse_language except ...
to hide the original ECLiPSe definition.

> 3)  SSY support the following declaration:
>       multifile user:help_info/4.
>    which I think says that-> To the predicate help_info/4,  "defined"
> in module "user",
>   new clauses can be added in the current file.
> I modified it to: (only in the first file)
>     dynamic user:help_info/4
>             However, this module does not exist anywhere in the code I
> am porting.

If you have loaded the quintus compatibility library (directly, or
indirectly through sicstus or swi), then the user-module exists.

> I suppose it is created on the fly in SSY, a feature which ECLIPSE
> does NOT support.
> To circumvent the "non-availability" of this feature I created the user module
> myself as  following:
> -----------user.ecl------------------
> :- module(user).
> help_info(A,B,C,D).
> ----------------------------
>       Then in the module I am working on, I included the delcaration
> :- lib(user).
> Upon compilation I am getting the error: ( I am using->
> lib(myLibraryName). to compile)
> [[type error in dynamic user : help_info / 4 in module fsa_array]]

Again, ECLiPSe's native dynamic directive does not recognise the module:
prefix, but the definition in lib(quintus)/lib(sicstus) does. You haven't
said which compatibility library you are using.  If you use swi, then
add in swi.ecl the line


to the reexport ... from quintus directive.

Furthermore, ECLiPSe doesn't allow (for good reasons) program clauses
to be module-prefixed.  We can however add limited support (for dynamic
clauses only) to the compatibility package as follows:

% Support Quintus-style "qualified clauses" (for dynamic predicates only)

:- export macro((:)/2, t_colon_clause/2, [clause]).

t_colon_clause(QualClause, []) :-
	( QualClause = (Module:Head:-Body) ->
	    Clause = (Head:-Body),
	    functor(Head, N, A)
	    QualClause = (Module:Clause),
	    functor(Clause, N, A)
	( current_module(Module) -> true ; create_module(Module) ),

I will add this to lib(quintus).

> what can be the problem?
> 4) How can one see all the "loaded modules " in the current instance of eclipse

Use current_module/1.

> 5) Is there any way/need of getting a "public declaration" for a
> predicate in ECLIPSE

This should more or less equivalent to export/1.  If you use lib(quintus)
or sicstus, it is already defined.  lib(swi) is lacking a reexport directive
for it (i'll fix that).

-- Joachim
Received on Mon Apr 30 2007 - 17:08:09 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 22 2019 - 12:14:57 CEST