First of all, you will always get a stack overflow when you try to print a circular object and *print-circle* is nil
. So, start with
(setq *print-circle* t)
Now, there are many ways to create a circular list:
(defparameter *my-circular-list* (list t))
(setf (cdr *my-circular-list*) *my-circular-list*)
==> #1=(T . #1#)
Note how the circular list is printed with #= so that it can be read:
(defparameter *my-circular-list-1* '#1=(t . #1#))
Warning: (equal *my-circular-list* *my-circular-list-1*)
will hang because it will infinitely descend into the circular structures.
You can also try this:
(setq *print-circle* nil
*print-length* 4)
(print '#1=(a . #1#))
==> (A A A A ...)
(setq *print-length* 10)
(print '#1=(a . #1#))
==> (A A A A A A A A A A ...)