Hi all,
I have a question. I want to load a file at runtime. See the example below:
% file 1: pp1.pl :- module(pp1, [m/0]). :- use_module(library(compiler)). m :- use_module(pp2, [test/0, s/1]), pp2:test, pp2:s(2), use_module(pp3), pp3:test, pp3:s(3).
% file: pp2.pl :- module(pp2, [test/0, s/1]). test :- message(['pp2']). s(X) :- message(['pp2:', X]).
% file: pp3.pl :- module(pp3, [test/0, s/1]). test :- message(['pp3']). s(X) :- message(['pp3:', X]).
When loading pp1.pl from ciao, the following error message appears: ?- use_module(pp1). {Compiling /cygdrive/d/pp1.pl ERROR: Bad module qualification of test/0, predicate not imported form module pp2 ERROR: Bad module qualification of s/1, predicate not imported form module pp2 ERROR: Bad module qualification of test/0, predicate not imported form module pp3 ERROR: Bad module qualification of s/1, predicate not imported form module pp3 } ?- yes
Can anyone tell me why the above program does not work.
Respectively Omar.
============================================================================== 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/ -----------------------------------------------------------------------------
Maybe someone can give me a hint. I tried the object oriented approach, e.g. the class(stack) example which comes with ciao and is used in the docs. Under both, Windows XP and Linux I get the same error:
?- use_package(objects). {Including ...} yes ?- use_class(library('class/examples/stack')). yes ?- St1 new stack. St1 = stack(tS9lmfFFFFFFF) ? yes ?- St1:push(8). {ERROR: user:push/1 - undefined predicate}
Thank you,
Georg Anker
============================================================================== 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/ -----------------------------------------------------------------------------
Dear George,
?- St1 new stack. St1 = stack(tS9lmfFFFFFFF) ? yes ?- St1:push(8). {ERROR: user:push/1 - undefined predicate}
In your latter call, St1 is already a variable again. The behavior is similar to:
?- X = 1. X = 1 ? yes
?- display(X). _158 yes
What you want is to continue the execution using the you got for the variables, i.e.,
?- St1 new stack, St1:push(8), St1:pop(Top). St1 = stack(iaJzXsrADEgjw), Top = 8 ? ;
This is what you'd probably do in a program. You can also use the 'continuation' facility of the Ciao toplevel (other Prolog systems may also implement it). Typing a comma (',') when the toplevel shows an asnwer tells it to continue the execution where it was before, without backtracking:
?- St1 new stack. St1 = stack('Ah23Od3ZjjrxG') ? ,
1 ?- St1:push(8). St1 = stack('Ah23Od3ZjjrxG') ? ,
2 ?- St1:pop(Top). St1 = stack('Ah23Od3ZjjrxG'), Top = 8 ? yes
2 ?- St1 = stack('Ah23Od3ZjjrxG') ? yes
1 ?- St1 = stack('Ah23Od3ZjjrxG') ? yes
Hope this helps.
============================================================================== 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/ -----------------------------------------------------------------------------
El jue, 23-06-2005 a las 11:02 +0200, Omar Nabil El Khatib escribió:
Hi all,
Hi,
I have a question. I want to load a file at runtime. See the example below:
% file 1: pp1.pl :- module(pp1, [m/0]). :- use_module(library(compiler)).
You should use import/2 to tell CIAO that your are going to load pp2 dynamically.
:- import(pp2, [test/0, s/1]). :- import(pp3, [test/0, s/1]).
m :- use_module(pp2, [test/0, s/1]), pp2:test, pp2:s(2), use_module(pp3), pp3:test, pp3:s(3).
Regards,