Re: Global predicates in SWI and Sicstus Prolog

From: Bart Demoen (bmd_at_cs.kuleuven.ac.be)
Date: 08/23/04


Date: Mon, 23 Aug 2004 13:34:19 +0200


>
> So, if I would use the same directive in a second module,
> the predicates would be different.

Ok. Second try. Checked it in SICStus and in SWI. Maybe not what you are
after.
Here are three files showing it:

% file3.pl
:- module(test2,[gee/1]).
:- load_files('file2.pl',[imports(all)]).

gee(X) :- bar(X).

% file2.pl
:- module(global,[bar/1]).

:- dynamic bar/1 .

bar(z).

% file1.pl
:- module(test,[foo/1]).
:- load_files('file2.pl',[imports(all)]).

foo(X) :- bar(X).

Session in SWI:

?- [file1, file3].
% file2.pl compiled into global 0.00 sec, 756 bytes
% file1 compiled into test 0.00 sec, 1,636 bytes
% file2.pl compiled into global 0.00 sec, 60 bytes
% file3 compiled into test2 0.00 sec, 872 bytes

Yes
?- assert(global:bar(qweqweqwe)).

Yes
?- assert(test:bar(test)).

Yes
?- assert(test2:bar(test2)).

Yes
?- test:foo(X).

X = z ;

X = qweqweqwe ;

X = test ;

X = test2 ;

No
?- test2:gee(X).

X = z ;

X = qweqweqwe ;

X = test ;

X = test2 ;

No

(and similar for SICStus)

You would have to put all global predicates in such a global module.
Unfortunately, one is not allowed to use user as the name of a
selfdefined module in SWi or SICStus :-(

The module qualification defaulting rules in MasterProlog are quite
different from those in SICStus, SWI (and others probably).
[I know because I implemented the ones in MasterProlog.]
If I needed to convert a set of modules from MasterProlog to SWI, I
would first adapt the program so that it did not use module user anymore
in MasterProlog - and then move to SWI.
I would expect that module user is your smallest problem when moving
from MasterProlog to SWI: metapredicates require more changes, no ?
And the $ syntax, and the module/3 predicate ...

I wish you luck !

Bart Demoen



Relevant Pages

  • Re: Global predicates in SWI and Sicstus Prolog
    ... >> So, if I would use the same directive in a second module, ... >> the predicates would be different. ... Checked it in SICStus and in SWI. ... > from MasterProlog to SWI: ...
    (comp.lang.prolog)
  • Re: CLP/FD: Sicstus vs Eclipse vs SWI
    ... guess, Sicstus is the best, the comes Eclipse and at last SWI. ... SICStus' clpfd is more recent, building on the cc(Van Hetenryck, ... Just a glance at the encyclopedic global constraint catalog ...
    (comp.lang.prolog)
  • Re: CLP/FD: Sicstus vs Eclipse vs SWI
    ... guess, Sicstus is the best, the comes Eclipse and at last SWI. ... Current systems by age: ... SICStus' clpfd is more recent, building on the cc(Van Hetenryck, ...
    (comp.lang.prolog)
  • Re: CLP/FD: Sicstus vs Eclipse vs SWI
    ... guess, Sicstus is the best, the comes Eclipse and at last SWI. ... I did this exercise long ago and selected SICStus for commercial ... good evaluation criteria. ...
    (comp.lang.prolog)
  • Re: CLP/FD: Sicstus vs Eclipse vs SWI
    ... guess, Sicstus is the best, the comes Eclipse and at last SWI. ... I did this exercise long ago and selected SICStus for commercial ... way and this was the main evaluation criteria ...
    (comp.lang.prolog)