r/C_Programming • • May 28 '26

Article The lone lisp heap

https://www.matheusmoreira.com/articles/lone-lisp-heap
1 Upvotes

7 comments sorted by

3

u/8d8n4mbo28026ulk May 29 '26

Very cool! I'm also somewhat experimenting around this same area, but pretty far away from an implementation for now. What you're doing with lone reminds me a bit of owl's lisp heap, but that has a compacting/moving GC.

With regards to the scanning, wouldn't a freelist work, or am I missing something? E.g.:

union actual_heap_value {
	struct lone_list_heap_value val;
	size_t next_free;
};

lone->heap.head = 0;

2

u/matheusmoreira May 29 '26

Great insight. Lone does have a compacting/moving garbage collector. The heap design presented in this article led directly to it. With compaction, it becomes feasible to track the index of the first free object for allocation purposes.

The next article will be about the moving/compacting GC!

1

u/matheusmoreira May 28 '26

Writing a lisp interpreter in freestanding C targeting Linux. This is the evolution of the heap implementation.

1

u/damofthemoon May 31 '26

Very good article to read 😄 Thanks Matheus!

2

u/matheusmoreira Jun 01 '26

I'm glad you enjoyed it!

1

u/un_virus_SDF Jun 03 '26

I made a freestanding shell and a freestanding brainfuck compiler. I may post about it some day.

There are some major crimes in there ( all I/O are unbuffered, some magic numbers when in the open syscall) but it works well.

1

u/matheusmoreira Jun 03 '26

I'd really enjoy reading about your freestanding projects, reach out when you publish?

Yeah currently there is very little buffering implemented. The reader has an input buffer and that's about it. The idea was to implement a buffered I/O module in lisp itself when the language was fully implemented. It's taking longer than anticipated.

I'll audit the existing system calls for magic numbers. Thanks for the feedback!