๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.prolog
3 messages
3 total messages Started by U37956 Wed, 11 Nov 1992 17:38
Retract static clauses, can't ?
#1585
Author: U37956
Date: Wed, 11 Nov 1992 17:38
19 lines
900 bytes
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:
   |- ? [mfile].

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.
Re: Retract static clauses, can't ?
#1586
Author: David I Schwartz
Date: Wed, 11 Nov 1992 21:11
24 lines
1324 bytes
> 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
Re: Retract static clauses, can't ?
#1588
Author: 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? *
*******************************************************************************
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads