2 ms·
Super dumb question: why not just use a queue, and visit the objects iteratively? Eg each visited object appends/prepends its children to the queue of objects
by olliej 9y ago
Super dumb question: why not just use a queue, and visit the objects iteratively?
Eg each visited object appends/prepends its children to the queue of objects to visit, and you just repeatedly drain until you have an empty list.
That’s what I had to do many years ago for the GC I was working on.
Then any special cases (like the cons case referenced elsewhere) just becomes performance optimization rather than “don’t crash” correctness