Re: [eclipse-clp-users] Looking for builtin variant of is/2 that suspends on Expr2

From: Joachim Schimpf <>
Date: Tue, 22 Dec 2009 13:11:04 +1100
-dp- wrote:
> Is there a builtin that does assignment like is/2 but suspends on the
> second parameter? (Another way of looking at it is that I'm looking for
> a variant of $= that does not suspend on Expr1 but instead does
> assignment once Expr2 is bound.)
> This seems like a very common need, but I can't find it in the list of
> builtins, nor in the similar predicates listed at the bottom of the
> pages about $=, =:=, is/2, etc.

You can switch the whole system into 'coroutine' mode where
all built-ins, if it makes sense, suspend instead of raising
instantiation faults:

[eclipse 1]: coroutine.
Yes (0.00s cpu)

[eclipse 2]: X is 3+Y, Y=1.
X = 4
Y = 1
Yes (0.00s cpu)

[eclipse 3]: atom_string(A,S), S="hello".
A = hello
S = "hello"
Yes (0.00s cpu)

The only potential problem with this solution is that this
setting has global (rather than module-wide) effect. Although
this is very unlikely to stop any existing code from working,
it makes it more difficult to find instantiation-related bugs.

Alternatively, of course, you can always suspend the goals explicitly:

[eclipse 2]: suspend(X is Y+1, 0, Y->inst), Y=3.
X = 4
Y = 3
Yes (0.00s cpu)

-- Joachim
Received on Tue Dec 22 2009 - 02:10:43 CET

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET