Re: follow up question (Re: cut and suspended goals)

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Fri 10 Sep 2004 10:02:58 AM GMT
Message-ID: <41417BD2.6030205@icparc.ic.ac.uk>
Tomas Uribe wrote:
> Here's another question about suspensions: The following code is not
> behaving as I would expect:
> 
> :- demon print_term/2.
> 
> print_term(D,Suspension) :-
>         printf("Term: %w\n",D),
>         (ground(D) -> kill_suspension(Suspension) ; true).
> 
> doit(D) :-
>         suspend(print_term(D,S),2,[D]->inst,S),
>         D = f(X), true,
>         D = f(a).
> 
> Executing doit(D) invokes print_term only once, printing "f(X)",
> returns with D bound to f(a), and leaves one suspended goal.
> 
> If I use "constrained" instead of "inst" I get the expected behavior:
> printing "f(X)", then "f(a)", and no suspended goals.
> But I thought that "inst" would do the trick too.
> 
> Is this a bug in "inst", or am I misunderstanding its behaviour?

That is the expected behaviour.

'inst' is interpreted as binding the variable to a nonvariable, and
that can happen only once (in this context, we don't consider the
instantiation of X as a "further instantiation of D").
For 'constrained'-ness this is different. Here we do consider the
instantiation of X as "further constraining D".

So, for your purposes, you should suspend on 'constrained'.

-- 
  Joachim Schimpf              /             phone: +44 20 7594 8187
  IC-Parc                     /      mailto:J.Schimpf@imperial.ac.uk
  Imperial College London    /    http://www.icparc.ic.ac.uk/eclipse
Received on Fri Sep 10 11:03:06 2004

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:08:24 PM GMT GMT