Programs perform a series of operations, some of which involve choices. They act as if they can always predict the right choice so that at the end of execution, it's made a set of choices that result in success.1 That path involves running calls, which run methods, which may run more calls, which select more methods, and so on. Thus far, we've avoided talking about how these different operations happen through time. That's because much of the time we can ignore it; it's an unnecessary detail to keep track of.
Nevertheless, operations are performed in a specific order. In particular,
If a method contains multiple operations — multiple calls, multiple pieces of output, or mixtures of calls and output — those operations are performed left-to-right. Thus, the leftmost operation is done first and the rightmost is done last.
That order can matter because each operation can change the state of the computer. In particular, it can change:
- The output by printing
- The values of variables by matching or using the
set
operation - The status of special predicates called fluents, whose definition can be changed during execution using the
now
operation.
You already know about output. Now we'll talk about each of the others, in turn.
Notes
-
Or, if there are no successful paths to choose from, it fails the original call.↩