Russ Abbott wrote:
Thanks to everyone who clarified the issue of references to external
variables. If an attempt to unify a value with an external variable
suspends, it's not clear to me why the following program produces an
output before suspending.
local X in
{Browse {SearchAll fun {$} X = x {Browse X} X end}}
end
I get an x in the browser--but no output from SearchAll.
Here comes an official explanation ;-)
Actually the unification inside the space does not block. It is given a
chance, but the binding of X is marked as "speculative". A speculative
binding has the property that the space might fail if the variable is
bound by its owner. In the example,
- if X is bound to 'x', the space succeeds;
- if X is bount to another value than 'x', the space fails.
In order to avoid a race condition, we say that the space is "unstable".
That is, an external binding may change its status. The operation
Space.ask (which is used by SearchAll) blocks until the space becomes
stable. Without stability, SearchAll would produce inconsistent output
results.
In the first example below, the search terminates because the constraint
Root=X is satisfied, whatever the value of X.
local X in
{Browse {SearchAll proc {$ Root} Root=X end}}
end
In the next example, the search completes too, showing no solution. The
speculative binding allows to detect failures earlier.
local X in
{Browse {SearchAll proc {$ Root} Root=X Root=1 X=2 end}}
end
Cheers,
raph
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users