# 13.4 Effect order and the tape

> Everything a program does towards the outside happens in program order and is noted on a **tape**, with which the run can be replayed without touching the world again.

Web page: https://pseudolearn.app/en/spec/motor/efectos

> **In one sentence**
>
> Everything a program does towards the outside happens in program order and is noted on a **tape**, with which the run can be replayed without touching the world again.

## 13.4.1 How it works

The **observable effects** are output, input, capability operations, the failure and the termination. They happen exactly in the order the language's rules prescribe. Effect-free computations may be reordered internally, but never in a noticeable way.

A statement that fails **produces no partial effects**. `Write` computes all its expressions before writing anything:

### Program: A Write that never gets to write

```pseudolearn
Algorithm SinParcial
  Define cero As Integer <- 0;
  Write "antes";
  Write "uno ", 1 Div cero;
EndAlgorithm
```

**Output**

```text
antes
```

**Diagnostics**
- `divisionByZero` (error, 4:19): Division by zero

*The program finishes with an error.*

**Figure 13.4-1: The effect tape**

A tape with three numbered entries: output, file and clock, joined by arrows. Below, the note that they are chained and that replaying gives the same run.

Every effect is noted on the tape with its number, its task and its result. Replaying the tape gives the same run without asking the host.

Every effect goes through two phases: **requested**, when its arguments are computed and it gets a sequence number, and **resolved**, when the host answers. The result is *committed*, *failed* or *uncertain*; reads are never uncertain.

The **tape** keeps the run's identity —code, profile, seed, limits— and one entry per effect, chained with a cryptographic digest. On replay everything is checked to match; secret data is stored redacted.

**In short**
- Effects happen in program order.
- A failing statement leaves no half-done effects.
- Every effect is requested, resolved and noted on the tape.
- The tape allows replaying the run exactly.

**See also**
- [11.4 Effects and capabilities](https://pseudolearn.app/en/spec/tareas/efectos.md)
- [1.4 Determinism: the same program always gives the same result](https://pseudolearn.app/en/spec/vision/determinismo.md)
