home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / prolog / 2063 < prev    next >
Encoding:
Text File  |  1992-11-12  |  2.4 KB  |  59 lines

  1. Newsgroups: comp.lang.prolog
  2. Path: sparky!uunet!mcsun!sunic!ugle.unit.no!sigyn.idt.unit.no!baustad
  3. From: baustad@idt.unit.no (Jostein Baustad)
  4. Subject: Re: Retract static clauses, can't ?
  5. Message-ID: <1992Nov12.145511.25582@ugle.unit.no>
  6. Sender: news@ugle.unit.no (NetNews Administrator)
  7. Reply-To: baustad@idt.unit.no (Jostein Baustad)
  8. Organization: The Norwegian Institue of Technology
  9. References: <92316.113830U37956@uicvm.uic.edu> <BxKLHy.Foy@acsu.buffalo.edu>
  10. Date: Thu, 12 Nov 92 14:55:11 GMT
  11. Lines: 46
  12.  
  13. In article <BxKLHy.Foy@acsu.buffalo.edu>, v104n55k@ubvmsb.cc.buffalo.edu (David I Schwartz) writes:
  14. |> > In article <92316.113830U37956@uicvm.uic.edu>, U37956@uicvm.uic.edu writes...
  15. |> > >Using Sicstus2.1 Prolog, I want to retract some facts (or clauses) which
  16. |> > >were loaded from a file.
  17. |> > >   Suppose in  mfile, there are facts:
  18. |> > >          johnlikes(mary).
  19. |> > >          marylikes(tom).
  20. |> > > 
  21. |> > >After starting prolog, i load the facts in the following way:
  22. |> > >   |- ? [Omfile].
  23. |> > > 
  24. |> > >When I try to remove a fact, such as:
  25. |> > >   |- ? retract((marylikes(tom))).
  26. |> > > 
  27. |> > >I got error message which says static terms can't be retracted.
  28. |> > > 
  29. |> > >How can i retract the facts and how can i made the facts dynamic ?
  30. |> > > 
  31. |> > >Could anyone tell me?
  32. |> > > 
  33. |> > >Thanks in advance.
  34. |> 
  35. |> You can try abolish (ie, abolish(marylikes/1) ) but it is rather extreme.
  36. |> 
  37. |> Dave
  38.  
  39. All predicates that are dynamic (i.e. that may be asserted or retracted) have
  40. to be declared so. Use
  41.  
  42. :- dynamic johnlikes/1, marylikes/1.
  43.  
  44. (The /1 is the arity of the predicate). I think the reason for this is
  45. efficiency reasons, since non-dynamic (static) predicates can be compiled into
  46. som more efficient representation. Hope this helps!
  47.  
  48. Jostein
  49.  
  50. -- 
  51. *******************************************************************************
  52. * Jostein Baustad                        * E-mail : baustad@idt.unit.no       *
  53. * The Norwegian Institute of Technology  * Mail   : Klµbuveien 122            *
  54. * Division of CS and Telematics          *          N-7031 Trondheim          *
  55. * Information and Knowledge Systems      *          Norway                    *
  56. *******************************************************************************
  57. * Queen's Park Rangers F.C. - SuperHoops ! If not us, who?; if not now, when? *
  58. *******************************************************************************
  59.