Reputation: 7486
Normally when the goal fail I get back "false" i.e. the goal was not satisfied.
Is there a way to make SWI-Prolog to print predicate, line and/or sequence number of the sub-goal where it failed.
I don't want to trace the whole program just want some feedback sort of like in other programming languages.
I know it is not error to return false
, but when debugging it will be nice to have this feedback to pinpoint problems. If it is possible of course.
thanks
Upvotes: 2
Views: 545
Reputation:
You might also want to consider using the "failure-slice" technique described many times by @false: it has its own tag.
Also, check out this great answer. You can use the code shown there to make your own "debugger" that lets you do (among other things) exactly what you are after.
Upvotes: 3
Reputation: 60034
maybe
...p1, p2, (p3;backtrace(10)), p4,...
could also be useful to start tracing after p3 is failing:
...p1, p2, (p3;backtrace(10),trace), p4,...
Upvotes: 0