Re: [eclipse-clp-users] Suspension: "constrained" does not wake on unification of ic variables

From: Joachim Schimpf <joachim.schimpf_at_...44...>
Date: Tue, 17 Nov 2009 09:46:58 +1100
Ulrich Scholz wrote:
> On Mon, Nov 16, 2009 at 11:21:32PM +1100, Joachim Schimpf wrote:
>> Ulrich Scholz wrote:
>>> Dear all,
>>>
>>> Id like to wake a suspension on an ic variables if it becomes more
>>> constrained, in particular, if it gets unified with another ic variable
>>> (#=).  
> 
>> What you have overlooked is that [bounds] reacts only to var-var
>> bindings within the set of variables on which a particular goal delays.
>> Bindings to unrelated variables don't trigger anything, which is exactly
>> the behaviour you need:
> 
> Thanks for the clarification.  Actually, it is not what I need because
> variables are created dynamically and at the time I set up the suspension I
> don't know to which they might be unified.  What to do?

The mechanism is that a suspension is only woken when it is on the bound-list
of _both_ variables that get unified.  That doesn't mean you have to know all
the variables in advance, you can add additional variables to the suspension
later using insert_suspension/4:

?- suspend(writeln(woken), 0, X->bound, Susp),
   insert_suspension(Y, Susp, bound of suspend, suspend),
   X=Y.
woken
X = X
Susp = 'SUSP-_585-dead'
Y = X
Yes (0.00s cpu)

Does that help?  Note that the mechanism is designed this way because
waking on unification with completely unrelated variables could cause
arbitrarily large slowdowns.


-- Joachim
Received on Mon Nov 16 2009 - 22:46:49 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 22 2024 - 18:13:20 CET