Re: strange problem with use_module

db <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
Hi Jan,


Le 03/03/2014 16:49, Jan Wielemaker a écrit :
> Dominique,
>
> It does not reproduce for me. That might be because there are some
> possibly relevant changes in the latest version. I did apply a small
> patch to avoid the trace on '$expand_goal'/2 and '$expand_term'/4.

on two of my computers there is the same behaviour
with the swi version 7.1.9.

>
> Unless you want to debug expansion logic, I suppose you do not want to
> step into use_module/1, so you use 'skip'.

Yes, if I use skip there is no error : the goal use_module(....)
succeeds.


  > The overall idea of Prolog
> debugging is to use 's' (skip) as much as possible.  If you see the
> wrong answer (often a failure), use 'r' (retry), step into (space)
> and start skipping again until you see where it goes wrong.

That is the way I use the debugger.

But in this case I was surprised by the fact that
use_module(my_module) succeeded displaying
a message (a path).
So I use the step by step graphical debugger to
see why, and the goal use_module(my_module) failed.
I was very suprised.

Anyway this is not a problem.

Thanks a lot for your answer.

Cheers,

Dominique

I was


>
>      Cheers --- Jan
>
> On 03/03/2014 02:52 PM, db wrote:
>> Hello Yan,
>>
>> Sorry for the lack of details, so here is a
>> very simple example which run
>> under Swi-prolog 64 bits, Version 6.6.1
>> (on ubuntu 12.04)
>> (the same problem appears with swi 7)
>>
>>
>> Consider 3 swi-prolog program,
>> test_module.pl, module1.pl and module2.pl
>> with :
>>
>>
>> test_module.pl
>> =====================================
>>    my_goal :-
>>       gtrace,
>>       use_module('module1.pl').
>> =====================================
>>
>> module1.pl
>> ====================================
>>    :- module(module1, []).
>>
>>    :- use_module('module2.pl').
>> ====================================
>>
>> module2.pl
>> ====================================
>>    :- module(module2, []).
>> ====================================
>>
>>
>> Now if you consult test_module.pl
>> and execute :
>> ?- my_goal.
>>
>> this lauches the graphical debugger.
>> If you use the right arrow (->) to enter in the goal
>> use_module('module1.pl'), you obtain :
>>
>> system:'$expand_term'(A, B, C, D) :-
>>      expand_term(A, B, C, D).
>>
>> with :
>>
>> A    = :-module(module1, [])
>> B    = term_position(0, 22, 0, 2, [term_position(3, 22, 3, 9, [10-17,
>> 19-21])])
>>
>> When you continue to click on the right arrow (->)
>> this finally fails with the error message :
>>
>> ERROR: Domain error: `module_file' expected, found
>> `/home/dominique/Bureau/Lea1_work/module1.pl'
>>
>> BUT :
>> If you restart from scratch (quit prolog, consult and execute my_goal).
>>
>> You again obtain the window of the graphical debugger.
>> if you use the arrow SKIP OVER (the third one from the left),
>> the goal succeeds.
>>
>> Why ?
>>
>> Thanks a lot if you have any explanation.
>>
>> Cheers.
>>
>> Dominique
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> Le 03/03/2014 09:14, Jan Wielemaker a �crit :
>>
>>> You make us guess what you are doing.  From `go into',
>>> I have the impression that you use use_module/1 as a
>>> normal goal inside a program to load code dynamically,
>>> right?
>>>
>>> I could imagine that this might lead to some mixup in the
>>> source handling, but a simple test shows everything works
>>> just fine.
>>>
>>> For short, as usual we need a complete example and instructions
>>> how to make it fail ...
>>>
>>> As a work-around, it might be wise to use 's' (skip) on the
>>> use_module/1 call.  Except for the execution of some hooks,
>>> nothing should be visible anyway and there is surely nothing
>>> you can debug with the gui tracer.
>>>
>>>     Cheers --- Jan
>>>
>>>>
>>>> Dominique
>>>>
>>>>
>>>> Le 02/03/2014 22:16, db a �crit :
>>>>> Hi Jeff,
>>>>>
>>>>> I have tried your solution but there is still
>>>>> the same problem :
>>>>>
>>>>> the instruction
>>>>> use_module(my_module) (without the extension .pl)
>>>>> works without the graphical debugger
>>>>> and does not work with it.
>>>>>
>>>>> Thanks for your answer.
>>>>>
>>>>> Regards
>>>>> Dominique
>>>>>
>>>>>
>>>>> Le 02/03/2014 19:48, Jeff Rosenwald a �crit :
>>>>>> Hi Dominique:
>>>>>>
>>>>>> It doesn't work at all on the Linux distro of SWIPL.
>>>>>>
>>>>>> Please try: "use_module(my_module)." That is, omit the extension
>>>>>> and see
>>>>>> if that changes the symptom.
>>>>>>
>>>>>> Regards,
>>>>>> Jeff R.
>>>>>>
>>>>>>
>>>>>>
>>>>>> -----Original Message-----
>>>>>> From: db <[email protected]>
>>>>>> To: swi-prolog <[email protected]>
>>>>>> Sent: Sun, Mar 2, 2014 12:01 pm
>>>>>> Subject: [SWIPL] strange problem with use_module
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> I use SWI-Prolog (Multi-threaded, 64 bits, Version 7.1.9)
>>>>>> on Ubuntu 12.04.
>>>>>>
>>>>>> In a program I have the instruction :
>>>>>>
>>>>>> use_module('my_module.pl').
>>>>>>
>>>>>> It works if I do not use the graphical debugger.
>>>>>>
>>>>>> But when I use the graphical debugger (with gtrace),
>>>>>> I obtain the following error :
>>>>>>
>>>>>> ERROR: /home/Dominique/create_int_examples.pl:49: Initialization goal
>>>>>> raised exception:
>>>>>> ERROR: Domain error: `module_file' expected, found
>>>>>> `/home/dominique/Documents/Recherche/completion2.pl'
>>>>>>
>>>>>> Anyone would have an explanation ?
>>>>>>
>>>>>> Thanks a lot
>>>>>>
>>>>>> Dominique
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> SWI-Prolog mailing list
>>>>>> [email protected]
>>>>>> <mailto:[email protected]>
>>>>>> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> SWI-Prolog mailing list
>>>>> [email protected]
>>>>> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>>>>>
>>>>>
>>>>>
>>>> _______________________________________________
>>>> SWI-Prolog mailing list
>>>> [email protected]
>>>> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>>> _______________________________________________
>>> SWI-Prolog mailing list
>>> [email protected]
>>> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>>>
>>>
>>>
>
>
> !DSPAM:152,5314a470188461741115069!
>
_______________________________________________
SWI-Prolog mailing list
[email protected]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.