(defvar x '(a))
(setf (cdr x) x)
(print x) ;; prints (a a a a a a a a ... forever until it crashes
There should be a way to mark objects during printing and then clear the mark, so that instead of printing infinitely, the above would print (a <recursive>) or something similar.
My idea for a solution:
void markobject (object *obj, bool target = true) {
Then supersub can mark each object after it prints it, and then markobject(obj, false) to clear the mark before returning. If it hits a marked object it prints <recursive> and returns without going any farther.
There should be a way to mark objects during printing and then clear the mark, so that instead of printing infinitely, the above would print
(a <recursive>)or something similar.My idea for a solution:
Then
supersubcan mark each object after it prints it, and thenmarkobject(obj, false)to clear the mark before returning. If it hits a marked object it prints<recursive>and returns without going any farther.