Caterpillar

Daily Thought - 2024-11-21

< back to list

My rewinding example from yesterday has a lot of overhead. A ratio of 5 undo instructions to just 3 regular ones! But it can be made cheaper by going more coarse-grained. For example, the latter two instructions push 2 and add, as a unit, can be undone with push 2 and sub, resulting in a 1:1 ratio. And a single pop can undo all three together (1:3).

I'm not sure yet what to do with this insight. Maybe the developer should have explicit control over how expressions are grouped into "undo units". Or the compiler could decide, based on some set of rules I have yet to work out. Guided by configuration that, for example, could limit the ratio of undo instructions to regular instructions.

I don't know. But I think this is one of those cases that I can work out when I actually get to it. And in any case, it's best to keep the initial implementation simple; just log undo instructions per instruction.

<< previous thoughtnext thought >>