Russ Abbott wrote:
    * It also strikes me as strange that apparently (and correct me if
      I'm wrong) it is not possible to execute 'choice' directly.  That
      is, one can't write {Digit} or  {Browse {Digit}} and expect a
      result.  But since 'choice' is part of the syntax of the language,
      as a programmer, my expectation is that it should do something,
      i.e., that the virtual machine that execute Oz programs would do
      something when it gets to a 'choice'.

Let me try to clarify things a bit. When a thread executes a choice statement, the program is facing a non-deterministic choice. Something *from the outside* must decide which alternative to choose. This is why the designers of Oz decided to encapsulate non-determinism. For this purpose they invented the computation space.

So your nondeterministic program is run inside a computation space. This space does not permit side effects, and thus looks like a closed world. From outside the space, you can detect when the space is facing a nondeterministic choice. There you can "guide" the computation by committing one of the alternives.

This makes a search engine easy to implement in Oz. Computation spaces are provided as first-class entities. Search consists in creating a computation space with the logic program inside it, and try all possible executions. For this, you wait until the computation succeeds, fails, or makes a choice. When facing a choice, you typically clone the space, and commit one of the alternatives per clone, and recursively explore them.


Cheers,
raph

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to