Article View: comp.lang.prolog
Article #1496Re: How to cleanup side effects after cut?
From: Arjen Duursma
Date: Mon, 28 Sep 1992 06:59
Date: Mon, 28 Sep 1992 06:59
53 lines
2334 bytes
2334 bytes
ludemann@quintus.com (Peter Ludemann) writes: >In article <525@tower1.uucp>, arjen@disnet.uucp (Arjen Duursma) writes: >> I am not sure because I do not know the appication at hand, but >> I think that a proper implementation of a cleanup would function like >> the next example. >> >> goal :- (sideeffects,somegoal);(undosideeffects,othergoal). >> >> If you find out that the sideeffects (like opening a file) where not >> needed, fail, and undo them. >> >> Hope that this is what you have been looking for. >> >If only it were so simple! >Consider: ?- goal, !, fail. >The cut will have removed the choice point created by the ";" >in goal/0, so undosideeffects/0 will not be executed. So define: oncegoal :- (sideeffects,somegoal,undosideeffects);(undosideeffects,othergoal),!. and use: ?- oncegoal. >What you need is something on the "choice point" stack which is executed >upon backtracking. Various Prologs have this for internal use, but I'm >not aware of any which provide it has a defined user predicate. (If your >Prolog has an interface to an RDBMS in which backtracking gets new rows, >chances are it has such a hidden predicate.) What you need is a good description of the use of the predicate you want to use. This description may tell you that have to use two predicates, one to make the mess (produce the answers) and one to clean things up. Just like: see/1 and seen/0, tell/1 and told/0. Any answers to the question that started this discussion is quite useless until there is a good description of what the predicate should do. The answer depends on the question. Anyway, I am still far from convinced that any special predicates to implement the requested funcionality. Just some experience in working with prolog. >-- > Peter Ludemann +1-415-813-3800 ludemann@quintus.com Arjen
Technical Details
Message-ID:
<539@tower1.uucp>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!disnet!arjenReferences:
<1992Sep17.093927.10525@neptune.inf.ethz.ch> <525@tower1.uucp> <1992Sep24.181035.5290@quintus.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!disnet!arjen From: arjen@disnet.uucp (Arjen Duursma) Newsgroups: comp.lang.prolog Subject: Re: How to cleanup side effects after cut? Keywords: cut, side effects, rewriting clauses Message-ID: <539@tower1.uucp> Date: 28 Sep 92 06:59:26 GMT References: <1992Sep17.093927.10525@neptune.inf.ethz.ch> <525@tower1.uucp> <1992Sep24.181035.5290@quintus.com> Organization: Disnet, IDE Maassluis, The Netherlands Lines: 53