I think you’ve a trivial error in your function definitions but I don’t think it’s relevant.
I think you’re right about avoiding cycles. I think the parent was talking about a let rec construction for data, e.g. in Haskell:
let funky_list = 1:2:3:4:funky_list
(Note that : is the cons operator).
If this is allowed then you may have issues. I think the problem is perhaps that the GC won’t work if you have pointers in the opposite of the normal direction. The fix though is relatively simple: add forwarding pointers (somehow), then after copying from the ‘B’ region to the ‘C’ region you leave behind a forwarding pointer and, if you see it again in your copying, you don’t make a duplicate copy of the data. Then I think you can proceed as before. But representing forwarding pointers efficiently is hard, I suspect.
Actually I think I don’t understand the GC sufficiently. Do you end up with a lot of memory usage after this or a little?
((LAMBDA (D Z) (D Z))
(QUOTE (LAMBDA (X)
(COND
(X ((LAMBDA (Y) (CONS Y Y)) (D (CDR X))))
((QUOTE T) (QUOTE T)))))
(QUOTE (A A A A A A A A)))
This should get you a binary tree about 8 levels deep with T on every leaf, and I think it should use linear memory (in the depth of the tree) but I don’t understand how the GC avoids ending up with an exponential amount of memory being used?