I don't like very much the explanation of Filip. I think it is confusing on some aspects. Let me try to clarify a bit...

Filip Konvička wrote:
Maybe the intentation is a bit confusing here. The choice creates a clone, but you carry on with the clone "ever after" the choice statement (i.e., the effects of the inside statements do not vanish with "end"). Think of "choice" as non-deterministic "if".

The "choice" is precisely a nondeterministic operator, and nothing more than that. The statement

   choice S1 [] S2 end

states that the program may execute either S1, or S2. That's all. There is basically no communication possible between alternatives.

The "choice" statement *does not* create a clone: clones are created by the search engine only. Cloning is used by the search engine to explore both possible executions of the program. Backtracking in Mozart is implemented by taking a clone of a former state of the encapsulated computation, and committing a not yet explored alternative.

A bit more about cloning: Remember that a computation space is a data structure that contains a (possibly nondeterministic) computation. Cloning a space means cloning the computation inside the space, and this includes threads, variables, and every thing created inside the space! So if a computation space uses a cell, that cell will be cloned with the space. Each clone of the space has its *own* cell. This is why there is no communication between clones. Actually the only possible communication must be done via a parent space.

Whenever the program "backtracks" beyond "choice", it also backtracks the value of FoundWord to what it was (i.e. false). More precise explanation is that the engine "forgets" the current branch (the one with @FoundWord==true) and re-starts from the "choice" statement, now taking the second alternative with @FoundWord==false. And

The computation has been cloned exactly when the program was stuck at the "choice" statement. At that point, the value of the cell was false. So when the search engine backtracks, it restarts with a computation where the cell has value false.

to get things even worse, note that the two alternatives can even be executed in parallel (concurrently), so there is IMHO really no "clean" way of the "first" having effect on the "second".

"Clones don't talk to each other." ;-)

Cheers,
raph

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

Reply via email to