Daily Thought - 2024-11-30
< back to listI've been talking about rewinding expressions using a runtime-based implementation. But what about a compiler-based approach? The information required to rewind already executed code is only available at runtime. So the work itself is definitely happening then. But the compiler can be responsible for orchestrating that work.
At its core, this would look similar to a runtime-orchestrated approach: There'd be some kind of buffer with information on how to undo an instruction, and that buffer would get filled, as regular (non-rewind) code gets executed.
So basically, the compiler would generate all of the following:
- Regular instructions, that do the things that need to get done.
- Interspersed with those, instructions that generate "undo data".
- Undo instructions, that use that undo data to undo the regular instructions.
Starting tomorrow, I'm going to take a closer look at this.
Hey, you! Want to subscribe to my daily thoughts? Just let me know (maybe include a nice message, if you're up for it), and I'll send you an email whenever I post a new one.