How can I include files or libraries dynamicaly in Ciao-Prolog?
You have to import the compiler, which is not imported by default to minimize executable size. Just include in the source:
:- use_module(library(compiler)).
Then, to use a module (as for example library(arrays)) execute the goal
..., use_module(library(arrays)), ...
and to use a user file (one which has no module definition) execute
..., ensure_loaded(mycode).
A problem is how to call predicates defined in this way, because the Ciao compiler complains that they are not visible at compile time. If the loaded file is a module, just precede the call with "_:", as in "_:new_array(A)", to inform the compiler the reference has to be interpreted at run-time. If it us a user file, include in the code
:- use_module(user, [predicate/1, another/2]).
if you want to call predicates predicate/1 and another/2 defined in that file.
Anyway, note that in most cases you do not need to invoke the compiler, for example if all you want to do is to read some data at start time. If you tell us for what use do you want to dynamicaly load a file, perhaps we can help you with a more efficient solution.
Daniel Cabeza ============================================================================== Message: Address: Action: help majordomo(a)clip.dia.fi.upm.es Info. on useful commands subscribe ciao-users-request(a)clip.dia.fi.upm.es Subscribe to this list unsubscribe ciao-users-request(a)clip.dia.fi.upm.es Unsubscribe from this list <whatever> ciao-users(a)clip.dia.fi.upm.es Send message to list ----------------------------------------------------------------------------- Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/ -----------------------------------------------------------------------------