Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!ccut!wnoc-tyo-news!ascwide!ascgw!sh8810!okilab!icot32!hawley From: hawley@icot32.icot.or.jp (David John Hawley) Newsgroups: comp.lang.prolog Subject: Re: co-routining Message-ID: <8203@icot32.icot.or.jp> Date: 18 Dec 90 01:36:22 GMT References: Distribution: comp Organization: Fifth Generation Computing Systems (ICOT), Tokyo, Japan Lines: 24 In article chikayama@icot.or.jp writes: >In article mark@adler.philosophie.uni-stuttgart.de (Mark Johnson) writes: > > * But what I don't know how to do is the following: define a predicate > * delay(Term, Goal) which calls Goal when Term is further instantiated, > * possibly by unifying distinct variables occuring in Term. > * Any ideas? >What's wrong with "freeze"ing a goal which, in addition to calling the >main "Goal", will traverse the data structure the variable is >instantiated to, hooking up the same goal to all the variables in the >structure on its way? For example: (context: SICStus Prolog) The problem with this is when you "unify distinct variables occuring in Term" to each other. The only predicate I know of that can capture such events is dif/2 (a sound implementation of \==), but I can't see how to use it to do what the first author wants. On the other hand freeze/2 waits for "instantiations", i.e. it doesn't trap Var=Var. David Hawley