Prolog goals order
I think the answer is that Prolog is not a theorem prover, but a
programming language. If I write write(a), write(b) I want "ab" and
not "ba", so order matters. If the system starts reordering things,
you as a programmer quickly do not feel in control any longer. If
you have two goals and you cannot put them in the right order because
it is depending on the runtime behaviour there are several options.
Use conditional code as in (Cond -> a,b ; b,a) or use coroutining:
?- freeze(X, X+1>10), read(X).
|: 10.
X = 10
Yes
2 ?-
Coroutining is not part of standard Prolog, but an increasing number
provide it. See also when/2 and dif/2. Note however this is a lot
more machinery, making it slower as well as more difficult to
understand.
--- Jan
|