Daily Thought - 2024-11-19
< back to listI'm sure there are many approaches for implementing expression-level rewinding, but the ones I could think of all boil down to a single principle: While you evaluate expressions, you log the information you need to undo those expressions later. Who does that logging, and what specifically is being logged, that's where the differences are.
As for who does the logging (or more precisely, who's responsible for making sure it happens), there are two candidates: the runtime and the compiler. I think having the compiler do it is more attractive overall, because that makes it easy to disable, leaving no runtime overhead; and because it's still going to work once Caterpillar is compiled to machine code (or WebAssembly).
But having the runtime do it might be the more practical option in the short term. As far as I can tell, that could be a relatively simple and robust solution, while having the compiler orchestrate it would be more complex, with more moving parts. Over the next few days, I'll be looking into this a bit more deeply.