I'm using cmucl-18e under FreeBSD and the following code doesn't work
while it works well with clisp:

--8<------------------------------------------------------
(defclass foo ()
  ((a :initarg :a :accessor a)
   (b :initarg :b :accessor b)))

(defun make-foo (a b)
  (make-instance 'foo :a a :b b))

(defparameter *my-readtable* (copy-readtable))
(make-dispatch-macro-character #\[ nil *my-readtable*)

(make-foo 1 2)
(setf a (make-foo 1 2))
(setf (a a) a)

(defmethod print-object ((object foo) stream)
  (with-slots (a b) object
    (format stream "[F ~W ~W]" a b)))

(defun read-foo (stream char n)
  (declare (ignore char n))
  (apply #'make-foo (read-delimited-list #\] stream t)))

(set-dispatch-macro-character #\[ #\F #'read-foo *my-readtable*)

(setf (b a) '())
(pushnew a (b a))

(defun toto (x)
  (push x (slot-value a 'b)))
(toto 1)
(toto 3)
(toto a)

(defmethod momo ((obj foo) x)
  (push x (b obj)))
(toto "othehunth")
(momo a 6)
(momo a a)
(setf *print-circle* t)
(print a)

(setf b (format nil "~W" a))

(setf c (let ((*readtable* *my-readtable*)) (read-from-string b)))
--8<------------------------------------------------------

Here's the error cmucl gives me:

--8<------------------------------------------------------
* (load "print-obj-test")

; Loading #p"/usr/home/manuel/print-obj-test.lisp".
Warning:  Declaring A special.


; In: LAMBDA (PCL::.PV-CELL. PCL::.NEXT-METHOD-CALL. OBJECT STREAM)

;   (SYMBOL-MACROLET (# #)
;     (FORMAT STREAM "[F ~W ~W]" # #))
; Error: Attempt to bind a special or constant variable with SYMBOL-MACROLET: A.
; 
;   (PCL::PV-BINDING (# # #:|pv-table|) . )
; --> PCL::PV-BINDING1 PCL::PV-ENV LET 
; ==>
;   (LET (#)
;     (BLOCK PRINT-OBJECT #))
; Note: Variable PCL::.SLOTS0. defined but never used.

Execution of a form compiled with errors:
 

Restarts:
  0: [CONTINUE] Return NIL from load of "print-obj-test".
  1: [ABORT   ] Return to Top-Level.

Debug  (type H for help)

(    )
Source: 
0] ba

0: (    )
1: (PRETTY-PRINT::OUTPUT-PRETTY-OBJECT  )
2: (COMMON-LISP::CHECK-IT )
3: (PRIN1  )
4: (PRINT  NIL)
5: (COMMON-LISP::SLOLOAD )
6: (COMMON-LISP::INTERNAL-LOAD   :ERROR :SOURCE)
7: (LOAD  :VERBOSE NIL :PRINT ...)
8: (INTERACTIVE-EVAL )
9: (COMMON-LISP::%TOP-LEVEL)
10: (COMMON-LISP::RESTART-LISP)
--8<------------------------------------------------------

Is this fix in a more recent version?

-- 
_Manuel Giraud_


Reply via email to