|
To be even more precise, Prolog programs only ever run forward because the order of evaluation is fixed as top-down, left-to-right. These notions of "forward" and "backward" are very unhelpful and should be given up. Beginners find the order of evaluation hard enough to understand, let's not confuse them even more. Also, the notion is woefully incomplete. Let's say we consider this "forward": ?- list_length([a, b, c], Length).
Length = 3.
Then you would say that this is "backward": ?- list_length(List, 3).
List = [_A, _B, _C].
Fine, but what's this then? "Inward"? ?- list_length([a, b, c], 3).
true.
And then presumably this is "outward": ?- list_length(List, Length).
List = [], Length = 0 ;
...
List = [a, b, c], Length = 3 .
None of these cases change the order of evaluation. They are all evaluated top-down, left-to-right. The sooner beginning Prolog programmers understand this, the better. The sooner we stop lying to people to market Prolog, the better. |