Crosscut

Daily Thought - 2024-11-23

Hey, I'm Hanno! These are my daily thoughts on Crosscut, the programming language I'm creating. If you have any questions, comments, or feedback, please get in touch!

This thought was published before Crosscut was called Crosscut! If it refers to "Caterpillar", that is the old name, just so you know.

< 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 >>

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.