Today I spent some time implementing a piece tree. It's not really a tree yet. It's more like a linked list. But I think the interface will be the same.
I've been curious about the piece tree for a while after having read a lot about it. And what better way to learn more and solidify that understanding than by implementing it? After getting a simple implementation working, I wanted to use it in the rest of rlworkbench and that work felt very hard. I was disappointed.
But I think I achieved something important that I didn't realize at first. I've never used a piece tree before. I've just read about it. Now I actually have an implementation in C. And I know how it works. I have advanced one step. Previously, my brain was focused on how a piece tree works and the benefits that it can give. Now that I actually have one, my brain can start thinking about how to use it in the context of rlworkbench.
I also got bogged down in details of C. And tried to reach perfection. That never ends well. Perhaps it's time to go back and use the application and work on improving what actually hurts the most. Right now, that might be that the copy & paste buffer has a memory limit. So if you try to copy or paste text that is too large, the application will crash. I have to figure out how to extend my arena implementation to allow arbitrarily much memory and how to represent strings spanning over multiple memory chunks. The piece tree might be one solution. But perhaps there are simpler solution for this particular problem. But now I have one more tool in my toolbox.
in #rlworkbench
What is Rickard working on and thinking about right now?
Every month I write a newsletter about just that. You will get updates about my current projects and thoughts about programming, and also get a chance to hit reply and interact with me. Subscribe to it below.