Running sbcl 1.3.7 in linux, I have an object which has a slot which is intentionally a circular list, following Rainer Joswig's advice in Circular list in Common Lisp and a global variable which is intended to be a proper list (not intended to be circular).
(setf *print-circle* t)
(defun circular (items)
(setf (cdr (last items)) items)
items)
(defclass circular ()
((items :accessor items :initarg :items)))
(defmethod initialize-instance :after ((c circular) &rest initargs)
(setf (slot-value c 'items)
(circular (slot-value c 'items))))
(defmethod next-item ((c circular))
(prog1 (first (slot-value c 'items))
(setf (slot-value c 'items)
(rest (slot-value c 'items)))))
(defparameter *notes* (make-instance 'circular :items '(A A# B C C# D D# E F F# G G#)))
(defparameter *stuff1* '(A A# B C C# D D# E F F# G G#))
(defparameter *stuff2* (list 'A 'A# 'B 'C 'C# 'D 'D# 'E 'F 'F# 'G 'G#))
My problem is the parameter *stuff1* which should be a simple list of symbols. Or so I thought. Compiling the above in sbcl, *stuff1* returns
> *stuff1*
#1=(A |A#| B C |C#| D |D#| E F |F#| G |G#| . #1#)
I definitely did not expect this non-circular list to turn into a Sharpsign Equal-Sign item. More to the point, even though I (setf *print-circle* t) the following hangs with no error from sbcl:
(member '|Bb| *stuff1*)
On the other hand, *stuff2* works as expected.
So, two questions, (1) why is the *stuff1* list turning into a circular cons, resulting in an improper list and *stuff2* stays a proper list and (2) how do I test membership in what *stuff1* has become?
Obviously I can use the *stuff2* version, but I am apparently misunderstanding something critical here. Any pointers are appreciated.