Search code examples
common-lispslimecircular-list

Forcing *print-circle* when loading a file into SBCL


I'm using a lot of circular lists in my code, and would like *print-circle* to be automatically set to t upon file load. I added the line (setf *print-circle* t) to my file, and thought that would help.

However, when I load the file into SLIME using C-c C-k, this doesn't seem to work - if I attempt to use the loaded code to print a circular list, the REPL gets thrown into an infinite loop unless I manually type (setf *print-circle* t) into the REPL after loading. I'm not sure precisely why this is happening - I only started getting this behaviour after I started using proper packaging and SLIME.

For the record, my package declarations (and anything else I thought might be relevant) are as follows:

(eval-when (:compile-toplevel :load-toplevel :execute)
  (ql:quickload "priority-queue")
  (load "utilities.fasl")) ;;to avoid compilation issues

(defpackage :tournament
  (:use :cl :priority-queue :utilities))

(in-package :tournament)

(setf *print-circle* t) ;should work, but doesn't

What am I missing?


Solution

  • You will need to wrap the setting of *print-circle* in an eval-when:

    (eval-when (:load-toplevel :execute)
      (setq *print-circle* t))