This is the nature of conservative gcs; it is only related to Lisp insofar as SBCL and ECL have conservative gcs. When there is a boundlessly growing list as in your example, a cons may eventually be retained by the gc, whereupon infinite storage will be required. This is the "false positive" mentioned in
(setf front (prog1 (cdr front)
(setf (cdr front) nil)))
For performance reasons this should be probably done even in CL implementations that don't have a conservative gc, as it can significantly reduce a gc's workload.
This is the nature of conservative gcs; it is only related to Lisp insofar as SBCL and ECL have conservative gcs. When there is a boundlessly growing list as in your example, a cons may eventually be retained by the gc, whereupon infinite storage will be required. This is the "false positive" mentioned in
http:// en.wikipedia. org/wiki/ Garbage_ collection_ %28computer_ science% 29#Precise_ vs._conservativ e_and_internal_ pointers
The solution is to break the chain by replacing
(setq front (cdr front))
with
(setf front (prog1 (cdr front)
(setf (cdr front) nil)))
For performance reasons this should be probably done even in CL implementations that don't have a conservative gc, as it can significantly reduce a gc's workload.