Kite: a pretty C with explicit control
Marconi
soldate at gmail.com
Sat May 2 15:51:12 UTC 2026
One important clarification about the Kite memory model:
When an object escapes and needs to be allocated on the heap, the
compiler calls on_heap. At that point, the owner can choose to
track the allocation:
```c
pointer on_heap(int size) {
pointer p = allocator.alloc(size);
heap_objects.add(p); // owner keeps track of heap allocations
return p;
}
```
From there, the programmer decides when to free memory:
delete obj;
Or, if desired, clean everything in one place:
```c
void cleanup() {
int i = 0;
while (i < heap_objects.length) {
delete heap_objects[i];
i = i + 1;
}
}
```
So the model is:
allocation may be implicit (stack vs heap decided by compiler)
but ownership and lifetime are explicit
the owner can track allocations and decide when to free them
forgetting to delete results in a memory leak (by design)
Kite separates allocation from lifetime, and puts lifetime
control in the hands of the owner.
This avoids hidden behavior while still allowing stack
optimization.
More information about the Digitalmars-d
mailing list