Sorry, I skipped this previous message (see also the answer for your later message regarding modules, also copied below). In the case of user files the solution is similar:
:- module(_,_).
:- import(user,[bar/1]).
main :- ensure_loaded(bar), bar(X).
Cheers, --Manuel H
From: ciao(a)clip.dia.fi.upm.es To: mcculloch <mccullochj(a)att.net> Cc: ciao-users(a)clip.dia.fi.upm.es Subject: Re: [Ciao-users] Run time loading Date: Sat, 13 Apr 2013 11:44:47 +0200
Hi John, not sure exactly if this is what you are looking for, but here is an example of how to load a module dynamically:
:- module(_,_).
:- import(bar,[b/1]).
main(X) :- use_module(bar), b(X).
The import declaration should only be used in these cases (see the manual). It only declares the interface: bar is not loaded until run time when the use_module call is executed (and can thus have different contents for each run).
A two-argument module declaration ':- module(_,_).' loads in the executable all the normal Prolog functionality and thus also the runtime compiler (needed for dynamic predicate load). If you are specifying the packages loaded by hand (i.e., using the third argument of the module declaration) then the runtime compiler is not loaded by default (useful for smaller executables) and you have to load it explicitly:
:- module(_,_,[]).
:- import(bar,[b/1]). :- use_module(library(compiler)).
main(X) :- use_module(bar), b(X).
Hope this helps! --Manuel H