Article View: comp.lang.prolog
Article #1490Re: How to cleanup side effects after cut?
From: Peter Ludemann
Date: Thu, 24 Sep 1992 18:10
Date: Thu, 24 Sep 1992 18:10
28 lines
1605 bytes
1605 bytes
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. 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.) -- Peter Ludemann +1-415-813-3800 ludemann@quintus.com
Technical Details
Message-ID:
<1992Sep24.181035.5290@quintus.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!infonode!ingr!capalo!quintus!quintus!ludemannReferences:
<1992Sep17.093927.10525@neptune.inf.ethz.ch> <525@tower1.uucp>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.prolog Path: arc1-ca.pugleaf.net!sparky!uunet!infonode!ingr!capalo!quintus!quintus!ludemann From: ludemann@quintus.com (Peter Ludemann) Subject: Re: How to cleanup side effects after cut? Message-ID: <1992Sep24.181035.5290@quintus.com> Keywords: cut, side effects, rewriting clauses Sender: news@quintus.com (USENET news account) Nntp-Posting-Host: canterbury Organization: Quintus Corporation, Palo Alto, CA References: <1992Sep17.093927.10525@neptune.inf.ethz.ch> <525@tower1.uucp> Date: Thu, 24 Sep 1992 18:10:35 GMT Lines: 28