🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #4083

Re: retractall and backtracking

#4083
From: David C. Sehr
Date: Fri, 09 Jun 1989 14:50
49 lines
2138 bytes
The reason that your predicate prints all the clauses for foo is
given in the Quintus manual, in chapter 14, on page 145 (version 2.3).
It says:

	Beginning with Release 2.0, the definition of an interpreted
	procedure that is to be visible to a call is effectively frozen
	when the call is made.  A procedure always contains, as far as
	a call to it is concerned, exactly the clauses it contained when
	the call was made.

This is exactly what happens when you call foo ahead of the retractall,
and hence all clauses for foo are still live until the last one is tried.

The Quintus solution renders clearer a favorite example of mine.
Try they following on your other favorite Prolog system and see the
result.

	a :- assertz(a), fail.
	?- a.

In C-Prolog 1.4 this will fail, whereas adding the clause (a :- fail)
after the first will succeed.  This is not at all a desirable situation
in my opinion, but is understandable in terms of the implementation of
choice points.

David

-----
David C. Sehr
Center for Supercomputing Research and Development
University of Illinois at Urbana-Champaign
305 Talbot Lab
104 South Wright Street
Urbana, IL 61801-2932

UUCP:	 {seismo,pur-ee,convex}!uiucdcs!uicsrd!sehr
ARPANET: sehr%uicsrd@a.cs.uiuc.edu
CSNET:	 sehr%uicsrd@uiuc.csnet
BITNET:	 sehr@uicsrd.csrd.uiuc.edu

-----
David C. Sehr
Center for Supercomputing Research and Development
University of Illinois at Urbana-Champaign
305 Talbot Lab
104 South Wright Street
Urbana, IL 61801-2932

UUCP:	 {seismo,pur-ee,convex}!uiucdcs!uicsrd!sehr
Technical Details
Message-ID: <1200@garcon.cso.uiuc.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!uxc!garcon!uicsrd.csrd.uiuc.edu!sehr
References: <575@hfserver.hfnet.bt.co.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!uxc!garcon!uicsrd.csrd.uiuc.edu!sehr
From: sehr@uicsrd.csrd.uiuc.edu (David C. Sehr)
Newsgroups: comp.lang.prolog
Subject: Re: retractall and backtracking
Keywords: Quintus, retract, backtracking
Message-ID: <1200@garcon.cso.uiuc.edu>
Date: 9 Jun 89 14:50:10 GMT
References: <575@hfserver.hfnet.bt.co.uk>
Sender: news@garcon.cso.uiuc.edu
Reply-To: sehr@uicsrd.csrd.uiuc.edu (David C. Sehr)
Organization: Center for Supercomputing R&D (Cedar), U. of Ill.
Lines: 49