Hi,
I'm having a few problems getting modules to work in ciao. I'd appreciate somebody pointing what I'm doing wrong. So I have one module in a file called plusdebug.pl which is something like this:
:- module(plusdebug,_)
debugger([]). debugger(Lst) :- ...
If I import this into the top level with ?- use_module(plusdebug).
Then I can use the predicate fine. If I try to use it within a file called analyser.pl, then I get problem. The second file has:
:- module(analyser,_) :- use_module(plusdebug).
... in a predicate later debugger([some,data]), ...
The predicate in analyser.pl always fails. Am I missing something about how modules work and how to import predicates from one module into another?
Amoss
PS The documentation is quite good, but in places (like the module section) it would be really good to have some concrete examples.
============================================================================== 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/ -----------------------------------------------------------------------------
Then I can use the predicate fine. If I try to use it within a file called analyser.pl, then I get problem. The second file has:
:- module(analyser,_)
(We assume that you are really putting the '.' at the end of :- module(analyser,_) of course and this is just a typo in the message: you would get a syntax error.)
:- use_module(plusdebug).
... in a predicate later debugger([some,data]), ...
The predicate in analyser.pl always fails. Am I missing something about how modules work and how to import predicates from one module into another?
Your understanding of modules is correct. But if you had a module access problem your predicate would not fail: you would get a compile-time error saying that debugger/1 is not imported. So, your predicate is most probably not failing bacause debugger/1 is not accessible, but for some other reason. You can always use the (source) debugger to find out where the failure comes from. If you still have problems if you send us the whole program we can probably find it for you. Hope this helps.
PS The documentation is quite good, but in places (like the module
Thanks!
section) it would be really good to have some concrete examples.
Noted.
Hi Amoss,
I have tried this and it works (Ciao-Prolog 1.10 #6):
-------- analyser.pl ------------ :- module(analyser,_). :- use_module(plusdebug).
main :- debugger([some,data]). --------------------------------- ------- plusdebug.pl ------------ :- module(plusdebug,_).
debugger([]). debugger(Lst) :- display(Lst). --------------------------------- In the Unix shell:
ciaosh
Ciao-Prolog 1.10 #6: Thu Dec 9 15:44:50 CET 2004 ?- use_module(analyser).
yes ?- main. [some,data] yes ?-
The lack of final dot in your module definitions occurs only in the mail or is in your code?
Regards,
Daniel
============================================================================== 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/ -----------------------------------------------------------------------------