๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1588

Re: Retract static clauses, can't ?

#1588
From: Jostein Baustad
Date: Thu, 12 Nov 1992 14:55
46 lines
2481 bytes
In article <BxKLHy.Foy@acsu.buffalo.edu>, v104n55k@ubvmsb.cc.buffalo.edu (David I Schwartz) writes:
|> > In article <92316.113830U37956@uicvm.uic.edu>, U37956@uicvm.uic.edu writes...
|> > >Using Sicstus2.1 Prolog, I want to retract some facts (or clauses) which
|> > >were loaded from a file.
|> > >   Suppose in  mfile, there are facts:
|> > >          johnlikes(mary).
|> > >          marylikes(tom).
|> > > 
|> > >After starting prolog, i load the facts in the following way:
|> > >   |- ? [Omfile].
|> > > 
|> > >When I try to remove a fact, such as:
|> > >   |- ? retract((marylikes(tom))).
|> > > 
|> > >I got error message which says static terms can't be retracted.
|> > > 
|> > >How can i retract the facts and how can i made the facts dynamic ?
|> > > 
|> > >Could anyone tell me?
|> > > 
|> > >Thanks in advance.
|> 
|> You can try abolish (ie, abolish(marylikes/1) ) but it is rather extreme.
|> 
|> Dave

All predicates that are dynamic (i.e. that may be asserted or retracted) have
to be declared so. Use

:- dynamic johnlikes/1, marylikes/1.

(The /1 is the arity of the predicate). I think the reason for this is
efficiency reasons, since non-dynamic (static) predicates can be compiled into
som more efficient representation. Hope this helps!

Jostein

-- 
*******************************************************************************
* Jostein Baustad                        * E-mail : baustad@idt.unit.no       *
* The Norwegian Institute of Technology  * Mail   : Klรฆbuveien 122            *
* Division of CS and Telematics          *          N-7031 Trondheim          *
* Information and Knowledge Systems      *          Norway                    *
*******************************************************************************
* Queen's Park Rangers F.C. - SuperHoops ! If not us, who?; if not now, when? *
*******************************************************************************
Technical Details
Message-ID: <1992Nov12.145511.25582@ugle.unit.no>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!ugle.unit.no!sigyn.idt.unit.no!baustad
References: <92316.113830U37956@uicvm.uic.edu> <BxKLHy.Foy@acsu.buffalo.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.prolog
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sunic!ugle.unit.no!sigyn.idt.unit.no!baustad
From: baustad@idt.unit.no (Jostein Baustad)
Subject: Re: Retract static clauses, can't ?
Message-ID: <1992Nov12.145511.25582@ugle.unit.no>
Sender: news@ugle.unit.no (NetNews Administrator)
Reply-To: baustad@idt.unit.no (Jostein Baustad)
Organization: The Norwegian Institue of Technology
References: <92316.113830U37956@uicvm.uic.edu> <BxKLHy.Foy@acsu.buffalo.edu>
Date: Thu, 12 Nov 92 14:55:11 GMT
Lines: 46