I mentioned this before, but I ran into it again.
It is extraordinarily frustrating for Oz to suspend silently when it runs into a choice statement outside a search.
In an earlier message, I presented a logic program solution to the Zebra problem. It had this structure.
local... % Other proc's including a non-determinstic Append/3fun {Zebra}
Nationalities = [english spanish japanese italian norwegian]
Colors = [green red yellow blue white]
Professions = [painter diplomat violinist doctor sculptor]
Pets = [dog zebra fox snails horse]
Drinks = [juice water tea coffee milk]
PropertyGroups = [Nationalities Colors Professions Pets Drinks]
Properties = {FoldR PropertyGroups Append nil} # Uses the non-deterministic Append/3 determinstically
Nb = {MakeRecord neighborProperties Properties}
in...Nb.english = Nb.red...Nb
end
in
{Browse {SearchAll Zebra}}
end
The line
Properties = {FoldR PropertyGroups Append nil}
works fine since it is executed within the SearchAll.
Since all the local variables are completely instantiated before the search starts, it should be equivalent to write the following.
localNationalities = [english spanish japanese italian norwegian]
Colors = [green red yellow blue white]
Professions = [painter diplomat violinist doctor sculptor]
Pets = [dog zebra fox snails horse]
Drinks = [juice water tea coffee milk]
PropertyGroups = [Nationalities Colors Professions Pets Drinks]
Properties = {FoldR PropertyGroups Append nil} # Uses the non-deterministic Append/3 determinstically
... % Other proc's including a non-determinstic Append/3fun {Zebra}
Nb = {MakeRecord neighborProperties Properties}in
...Nb.english = Nb.red...
Nb
end
in
{Browse {SearchAll Zebra}}
end
If you run this, it will suspend silently on the line
Properties = {FoldR PropertyGroups Append nil}
because Append is defined using choice. I know there are other ways to write this to make it work. But my point is that this way should either work or some diagnostic should tell you that the program is ill-structured. One way to make it work is to launch an implicit SearchAll and raise an exception if you get more than one answer. Alternatively, a way to produce a diagnostic is to trace paths outside the SearchAll and produce an error message if a path leads to a choice statement. As it is, it produces great frustration to make what seems to be an innocent program transformation and find that the resulting program seems to do nothing.
-- Russ
_________________________________________________________________________________ mozart-users mailing list [email protected] http://www.mozart-oz.org/mailman/listinfo/mozart-users
