Hi Jim,
When I try to use the package in the subject heading I get
{ERROR: absolute_file_name/7, arg 1 - existence error: source_sink:library (use_occurs_check) does not exist}
what should I be using in order to have access to the predicate
unify_with_occurs_check/2 ?
This depends on your context. In the top level (which loads by default 'iso-misc') you do not need to do anything: it is loaded by default.
?- unify_with_occurs_check(X,Y).
Y = X ?
yes ?- unify_with_occurs_check(X,f(X)).
no ?-
The same happens in a module that uses a traditional module declaration, e.g.:
:- module(_,_).
p(X,Y) :- unify_with_occurs_check(X,Y).
since those modules load the same packages as the top level (the set of 'builtins' that is normally provided by standard Prologs). The same happens also in a "user" file (a file with no module declaration): those also load the same modules as the top level.
If you specify packages in the module declaration (including 'no packages', as below), then you have to load iso-misc explicitly:
:- module(_,_,[]).
:- use_module(library(iso_misc)).
p(X,Y) :- unify_with_occurs_check(X,Y).
In this mode one can control specifically which modules and packages are loaded and which not so that, e.g., one can make sure that no unwanted predicates (e.g., assert/retract, higher-order, side-effects, ...) are visible from a given module.
How to figure out that unify_with_occurs_check/2 is in iso_misc?
- In the manual: look in the index for unify_with_occurs_check/2 and it points you to iso_misc.
- Much easier: in the graphical environment. E.g., within emacs, in a .pl file (or the top level) put the cursor on unify_with_occurs_check and do 'C-c TAB', and this will take you to the manual page. The module is on the emacs mode line.
Hope this helps.
Manuel H