Daily Thought - 2024-10-16
< back to listThe idea of having memory management strategies
that are not directly built into the language is not new.
malloc
is just a function after all. Rust has the Box
type, and
Rc
/Arc
. Zig adds another twist and requires an explicit allocator to
reserve memory on the heap.
As I've been working on this series of daily thoughts, I've realized what I want for Caterpillar is basically region-based memory-management. A region would be represented as a value in the language. Different types of regions could provide different memory management strategies. And they'd use the linear type system to make that sound, and as error-proof as they need to.
This also fits with the host concept. The core language would only know about the stack. Access to the heap is provided by the host. I assume there would be standardized interfaces, that region types written in Caterpillar could build on. But also host-specific region types. A host running on a desktop or server OS could provide different regions than one running on a microcontroller.