Caterpillar

Daily Thought - 2024-11-23

< back to list

Rewinding instructions is not trivial, because instructions are not atomic and can fail partway through. Let's understand this a little better. Instructions look at the state of the runtime, then decide how to change that. But the changes they can make are very limited. Push a value, pop a value, set the address of the next instruction; stuff like that.

Let's call those actions "micro-instructions". Micro-instructions are much simpler than regular instructions. They don't decide anything; they just make a change, independently of the runtime state. And there are fewer of them. Maybe just a handful, versus currently 31 regular instructions (with more to come, I'd guess).

So what if we log micro-instructions as undo instructions? Then we can undo partially executed instructions just as easily. And the code that creates undo instructions becomes much simpler, because there are far fewer micro-instructions to consider.

<< previous thoughtnext thought >>