Russ Abbott wrote:
Define a proc Unify/3 that attempts to unify its first two arguments and
sets its third argument to true/false depending on whether not it succeeds.
local
proc {Unify X Y Z}
try X = Y Z = true
catch _ then Z = false
end
end
A B
in
if {Unify [A b a] [a B B]} then {Browse 1#A#B}
elseif {Unify [A b] [a B]} then {Browse 2#A#B}
end
end
It would be even nicer if value.'=' were defined as both =/2 and =/3,
with the latter being defined as above.
Sorry, the logic part of Oz is not an inclusion of Prolog. Unification
and testing for equality are distinct in Oz. The base model of Oz
(concurrent constraints) requires to distinguish between both.
The statement X=Y tells the constraint X=Y to the store, while X==Y asks
whether the store entails X=Y. The latter blocks if the constraint
store does not contain enough information.
This behavior combines very naturally with concurrency. Testing
equality cannot tell extra constraints to the store (like Prolog would).
A "speculative" unification is problematic, because backtracking one
thread would require to backtrack all threads in the system. That is
unreasonable to implement.
Cheers,
raph
_________________________________________________________________________________
mozart-users mailing list
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users