State-passing treats state as an explicit input and returns the resulting updated state from the computation. It provides a pure, functional imitation of mutation without destroying the previous value. section 7.2.1 section 7.1
The basic design is straightforward: supply the current state, perform a calculation, and return the new state. An interpreter can therefore traverse nested methods while threading Runtime through each call; nested interpreters receive the appropriate outer interpreter as an argument. section 5.3.2
Updating a spaceship model
A rotation script reads the spaceship's mass, calculates a thruster impulse, recalculates the mass, and repeats the process. Each step produces a new model for the next step rather than modifying the previous model directly. section 7.2.1
The approach becomes cumbersome when state is deeply nested or when every operation also returns Either or Maybe for errors and optional values. State monads package the same underlying technique into a monadic form, while mutable references can be more convenient at an implementation boundary or in concurrent systems. section 7.2.1 section 7.3
