🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #1080

Freezing and Copyterm

#1080
From: Matthew Crocker
Date: Tue, 14 Aug 1990 15:28
32 lines
1492 bytes
Hello,
  I'm having a problem with the goal freezing directive, which is
  illustrated by the code below. Roughly, while do1 is waiting for X
  to be instantiated, do2 creates Y -- a copy of X -- and instantiates
  Y = 2. This seems to "fake-out" the freeze, which thinks that X
  is now instantiated as 2. Afterwards, however, when X is set to 1
  do1 executes again (it almost looks like X is receiving multiple
  assignments, since do1 prints it's value as 2 then 1).

  A response from SICStus (Mats Carlsson) pointed out that copyterm
  also copies the any constraints (as does the usual assert/retract
  version of copyterm).

  Is this intended? Are there any alternatives to copy_term(X,Y) which
  create a Y truly independent of X.

Matt Crocker
mwc@aipna.ed.ac.uk
---------------------
%SICStus Prolog: test of freeze.
main :-
   do1(X),
   do2(X),
   X=1.

:- wait do1/1.
do1(X) :-           %When X gets instantiated, print it.
   write(X).

do2(X) :-
   copy_term(X,Y),  Ccreate an independent copy of X.
   Y=2.
Technical Details
Message-ID: <2760@aipna.ed.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!mcsun!ukc!edcastle!aipna!mwc

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!uunet!mcsun!ukc!edcastle!aipna!mwc
From: mwc@aipna.ed.ac.uk (Matthew Crocker)
Newsgroups: comp.lang.prolog
Subject: Freezing and Copyterm
Keywords: freezing, coroutining, SICStus
Message-ID: <2760@aipna.ed.ac.uk>
Date: 14 Aug 90 15:28:12 GMT
Reply-To: mwc@aipna.ed.ac.uk (Matthew Crocker)
Organization: Dept of AI, Edinburgh University, UK.
Lines: 32