Skip to content

SpecificationXIII · The engine inside

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.

Markdown version

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:

ProgramA Write that never gets to write

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

Output

antes

Diagnostics

  • divisionByZero · error · 4:19 · Division by zero

The program finishes with an error.

Figure 13.4-1.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.

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 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.