Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!eos!labrea!sri-unix!quintus!ok From: ok@quintus.uucp (Richard A. O'Keefe) Newsgroups: comp.lang.prolog Subject: Re: The double-cut. Message-ID: <227@quintus.UUCP> Date: 2 Aug 88 04:16:55 GMT References: <1162@ttds.UUCP> <208500002@s.cs.uiuc.edu> Sender: news@quintus.UUCP Reply-To: ok@quintus.UUCP (Richard A. O'Keefe) Organization: Quintus Computer Systems, Inc. Lines: 43 In article <208500002@s.cs.uiuc.edu> gooley@s.cs.uiuc.edu writes: >Some debuggers on some systems (C-Prolog is one, I think) show apparent >retries of deterministic system calls. Might this be misleading people >into thinking that cuts are needed to prevent such retries in actual >execution? "Four-port" debuggers are _supposed_ to show "redo"s of built-in predicates. As you can easily determine by writing e.g. my_abolish(F, N) :- ( write(call), nl, fail ; true ; write(fail), nl, fail ), abolish(F, N), ( write(exit), nl, fail ; true ; write(redo), nl, fail ). and doing | ?- my_abolish(foo, 10), foo = 10. the "redo"s are _happening_, so naturally they get shown! (I get four lines of output: "call", "exit", "redo", "fail".) In Edinburgh-style debuggers, it is important to distinguish between REDO which is what happens of itself when something downstream fails, and RETRY which is what happens when you give a r)etry command, and involves re-executing a goal from the start. ReTRYing a command will indeed cause it to happen again, e.g. | ?- write(retry), fail. % in trace mode (3) 0 Call (built_in): write(retry) ? retry (3) 0 Exit (built_in): write(retry) ? r %-----------------------------------------------------^ explicit reTRY [Debugger: retry goal] (3) 0 Call (built_in): write(retry) ? %----------------^^^^ restarted this goal from the beginning retry (3) 0 Exit (built_in): write(retry) ? (3) 0 Redo (built_in): write(retry) ? %----------------^^^^ reDO caused by downstream failure (3) 0 Fail (built_in): write(retry) ? %----------------^^^^ immediately fails without having done anything more no Cuts not only aren't needed to prevent retries, they can't prevent them. But a debugger should not retry a goal unless you explicitly tell it to. Would it be clearer if the "redo" port were renamed to "Next" (short for "please give me your next solution"? (C Prolog actually calls this port "Back", I think, because the debugger isn't _quite_ a four-port one.)