Re: Global predicates in SWI and Sicstus Prolog
From: Bart Demoen (bmd_at_cs.kuleuven.ac.be)
Date: 08/23/04
- Next message: Christoph Quix: "Re: Global predicates in SWI and Sicstus Prolog"
- Previous message: Christoph Quix: "Re: Global predicates in SWI and Sicstus Prolog"
- In reply to: Christoph Quix: "Re: Global predicates in SWI and Sicstus Prolog"
- Next in thread: Christoph Quix: "Re: Global predicates in SWI and Sicstus Prolog"
- Reply: Christoph Quix: "Re: Global predicates in SWI and Sicstus Prolog"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Christoph Quix: "Re: Global predicates in SWI and Sicstus Prolog"
- Previous message: Christoph Quix: "Re: Global predicates in SWI and Sicstus Prolog"
- In reply to: Christoph Quix: "Re: Global predicates in SWI and Sicstus Prolog"
- Next in thread: Christoph Quix: "Re: Global predicates in SWI and Sicstus Prolog"
- Reply: Christoph Quix: "Re: Global predicates in SWI and Sicstus Prolog"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|