[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



; The following illustrates the problem I am encountering with #n= in
; output.  Because the call to write calls the format in the defstruct
; print routine, the #n= count is reset between defstruct prints, resulting
; in both structures using #0= to define their shared substructure and making
; it impossible to read the list back in.
; This is apparently a shortcoming of the original definition of CL. Page
; 559 of CLtLII alludes to the problem.
; Jon.

(defstruct  (sister-ship (:print-function print-sister-ship)) class members )

(defstruct (ship) hms )

(defun print-sister-ship (x stream depth)
  (format stream 
	  "#s(sister-ship class ~s members ~s)"
	  (sister-ship-class x)
	  (sister-ship-members x)))

(defun bug ()
  (setf x (make-ship :hms 'santa-maria))
  (write `(
	   ,(make-sister-ship :class 'nina
			      :members `(,(symbol-value 'x),(symbol-value 'x)))
	   ,(make-sister-ship :class 'pinta
			      :members `(,(symbol-value 'x),(symbol-value 'x))))
	 :stream (open "bug" :direction :output)
	 :escape t
	 :circle t
	 :pretty t))