Re: How to use predicate of library w/o loading the library?

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Mon 06 Dec 2004 06:29:53 PM GMT
Message-ID: <41B4A521.3040001@icparc.ic.ac.uk>
Ulrich Scholz wrote:
> 
> I like to use unify_with_occurs_check of the iso library - but I don't
> want to load that library:

Yes, you do want to _load_ it :-)
What you don't want is to _import_ everything it defines.
The trouble is that lib/1 and use_module/1 do both!


> 
> By now, I use
> 
> :- (import (unify_with_occrs_check)/2 from iso).
> 
> This works as it allows to use the predicate without the negative side
> effects of loading iso.  But, it produces the warning
> 
> WARNING: module 'iso' does not exists, loading library...
> 
> I guess, I'm doing something wrong.  How to do it better?

You should write

:- ensure_loaded(library(iso)).
:- import unify_with_occurs_check/2 from iso.

where ensure_loaded/1 will only load the library but not import
anything. Then you can explicitly import only the bits you need.



If you only want a unification with occurs check, you could
alternatively try using the definition

unify_with_occurs_check(X, X) :- acyclic_term(X).



-- 
  Joachim Schimpf              /             phone: +44 20 7594 8187
  IC-Parc                     /      mailto:J.Schimpf@imperial.ac.uk
  Imperial College London    /    http://www.icparc.ic.ac.uk/eclipse
Received on Mon Dec 06 18:31:49 2004

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:31 PM GMT GMT