Re: Metainterpreter that prints call stack in case of failure.
From: Maurizio Colucci (look_at_in.signature)
Date: 07/02/04
- Next message: Bart Demoen: "Re: Metainterpreter that prints call stack in case of failure."
- Previous message: Magellan: "Re: Little problem please help"
- In reply to: Jan Wielemaker: "Re: Metainterpreter that prints call stack in case of failure."
- Next in thread: Bart Demoen: "Re: Metainterpreter that prints call stack in case of failure."
- Reply: Bart Demoen: "Re: Metainterpreter that prints call stack in case of failure."
- Reply: Jan Wielemaker: "Re: Metainterpreter that prints call stack in case of failure."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 02 Jul 2004 09:19:54 GMT
Jan Wielemaker wrote:
>
> goal_expansion(Term, fcall(Term)) :-
> callable(Term),
> functor(Term, Name, Arity),
> must_succeed(Name/Arity). % left to the user
>
> fcall(Goal) :-
> ( Goal
> *-> true
> ; functor(Goal, Name, Arity),
> format(user_error, 'Unexpected failure of ~w/~d~n', [Name, Arity]),
> backtrace(10) % number of parents displayed
> ).
>
Hello again :-)
I understood the mechanism, but there is a problem...
I tried calling run/0 with the input file:
must_succeed(run/0).
run:-
dontFail([hello, world]).
dontFail(L):-
member(hello, L),
member(jack, L). % THIS will fail
goal_expansion(Term, fcall(Term)):-
callable(Term),
functor(Term, Name, Arity),
must_succeed(Name/Arity).
fcall(Goal):-
( Goal ->
true;
( functor(Goal, Name, Arity),
format(user_error, 'Unexpected failure of ~w/~d~n', [Name, Arity]),
backtrace(10))).
The output is the following:
Unexpected failure of run/0
[8] prolog_stack:backtrace/1
at /usr/lib/pl-5.3.14/library/prolog_stack.pl:127
[6] '$execute_goal2'/2 at /usr/lib/pl-5.3.14/boot/toplevel.pl:508
[3] prolog/0 at /usr/lib/pl-5.3.14/boot/toplevel.pl:361
[2] '$runtoplevel'/0 at /usr/lib/pl-5.3.14/boot/toplevel.pl:333
[1] '$toplevel'/0 at /usr/lib/pl-5.3.14/boot/toplevel.pl:319
The problem is that the error message does not point me to the actual
subcall that failed:
member(jack, [hello, world])
Furthermore, the backtrace starts from run/0, so it is not much useful. It
should start from member(jack, [hello,world])...
I am not sure what I should change to solve this...
-- Best Regards, Maurizio Colucci Please remove the uppercase letters "S,P,A,M": seSgPuAsMo.forever@tin.it
- Next message: Bart Demoen: "Re: Metainterpreter that prints call stack in case of failure."
- Previous message: Magellan: "Re: Little problem please help"
- In reply to: Jan Wielemaker: "Re: Metainterpreter that prints call stack in case of failure."
- Next in thread: Bart Demoen: "Re: Metainterpreter that prints call stack in case of failure."
- Reply: Bart Demoen: "Re: Metainterpreter that prints call stack in case of failure."
- Reply: Jan Wielemaker: "Re: Metainterpreter that prints call stack in case of failure."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]