[m-rev.] for review: implement undo for declarative debugger

Ian MacLarty maclarty at cs.mu.OZ.AU
Tue Jul 26 12:41:07 AEST 2005


On Tue, 26 Jul 2005, Ian MacLarty wrote:

> On Tue, 26 Jul 2005, Julien Fischer wrote:
>
> >
> > On Mon, 25 Jul 2005, Ian MacLarty wrote:
> >
> > > For review by anyone.
> > >
> > > Estimated hours taken: 6
> > > Branches: main
> > >
> > > Implement `undo' command in the declarative debugger.
> > > The `undo' command takes the debugger back to the state it was in before the
> > > last answer was given (`skip' is counted as an answer in this case).
> > >
> > >

I've also just added the following change which checks that the oracle answer
came from the user before pushing the state of the diagnoser onto the history
stack.  This is not necessary because the oracle is consulted as the search
space is searched, so the analyser shouldn't ask questions of the oracle which
the oracle already has answers to in its knowledge base.  However if this
changes in the future I don't want the undo command to break.

I have added the following to the CVS log under declarative_oracel.m:
	Report whether an answer came directly from the user or not in
	query_oracle.

diff -u browser/declarative_debugger.m browser/declarative_debugger.m
--- browser/declarative_debugger.m	25 Jul 2005 10:40:59 -0000
+++ browser/declarative_debugger.m	26 Jul 2005 02:18:34 -0000
@@ -446,8 +446,9 @@
 	;
 		true
 	),
-	query_oracle(Question, OracleResponse, Oracle0, Oracle, !IO),
+	query_oracle(Question, OracleResponse, FromUser, Oracle0, Oracle, !IO),
 	(
+		FromUser = yes,
 		OracleResponse = oracle_answer(_)
 	->
 		push_diagnoser(!Diagnoser)
diff -u browser/declarative_oracle.m browser/declarative_oracle.m
--- browser/declarative_oracle.m	25 Jul 2005 08:54:13 -0000
+++ browser/declarative_oracle.m	26 Jul 2005 02:18:03 -0000
@@ -89,12 +89,15 @@
 	%
 :- pred get_trusted_list(oracle_state::in, bool::in, string::out) is det.

+	% query_oracle(Question, Response, AnswerFromUser, !Oracle, !IO).
 	% Query the oracle about the program being debugged.  The first
 	% argument is a node in the evaluation tree, the second argument is the
 	% oracle response.  The oracle state is threaded through so its
 	% contents can be updated after user responses.
+	% If the response came directly from the user then AnswerFromUser
+	% will be yes, otherwise it will be no.
 	%
-:- pred query_oracle(decl_question(T)::in, oracle_response(T)::out,
+:- pred query_oracle(decl_question(T)::in, oracle_response(T)::out, bool::out,
 	oracle_state::in, oracle_state::out, io::di, io::uo) is cc_multi.

 	% Confirm that the node found is indeed an e_bug or an i_bug.  If
@@ -159,15 +162,17 @@
 :- import_module set.
 :- import_module std_util.

-query_oracle(Question, Response, !Oracle, !IO) :-
+query_oracle(Question, Response, FromUser, !Oracle, !IO) :-
 	(
 		answer_known(!.Oracle, Question, Answer)
 	->
-		Response = oracle_answer(Answer)
+		Response = oracle_answer(Answer),
+		FromUser = no
 	;
 		make_user_question(!.Oracle ^ kb_revised, Question,
 			UserQuestion),
-		query_oracle_user(UserQuestion, Response, !Oracle, !IO)
+		query_oracle_user(UserQuestion, Response, !Oracle, !IO),
+		FromUser = yes
 	).

 :- pred make_user_question(oracle_kb::in, decl_question(T)::in,

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list