Russ Abbott wrote:

Hi Torsten,
Thanks for the interesting example. I'll admit to being confused about the status of 'or'. It doesn't appear in CTM. The only reference to it in the Global Index is to Bool.'or'. Even that is misleading. It claims that Or always evaluates both arguments, but declare X
 {Browse {Or X == 0 true}}
suspends instead of returning true.

The Bool.'or' is not the same as the statement or ... end.
Bool.'or', also known as Or, is a function of two boolean arguments
that returns a boolean.  If X is unbound then X==0 will suspend, so
the Or will not execute.

But more to the point. The 'or' control structure you mention is described in 12.5 of the tutorial. (http://www.mozart-oz.org/documentation/tutorial/node12.html#label72 <http://www.mozart-oz.org/documentation/tutorial/node12.html#label72>). I couldn't find it anywhere else. From that description and the explanation in 12.7.1, I was able to see how it differed from 'choice' and 'dis' but not how 'choice' and 'dis' differed from each other.

The real primitive is 'choice'. It makes a choice point so that a search engine can choose between all the alternatives. The 'dis' is a derived version that removes all choices whose guards evaluate to false, and if there is only one choice left, will immediately execute that choice without creating a choice point. If more than one choice is left, a choice point with only those choices will be created. This is called 'determinacy directed execution', also known as the 'Andorra principle' since
it was first used in a Prolog variant called Andorra.

(Note that the 'or' statement does not create a choice point at all. It tries
immediately to pick between alternatives and if it can't decide, it will
simply suspend.  Search engines don't see 'or'.)

We now know that 'dis' is actually not a good idea. 'dis' tries to be smarter when doing backtracking, but it still goes the generate-and-test route of Prolog. Much better is to use the pruning technique of constraint programming. So that's why
we consider 'dis' as deprecated and why CTM does not mention it.

I hope that this clarifies things a bit!

Peter


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

Reply via email to