Conditions and *PRINT-READABLY*
Edi Weitz
edi at weitz.de
Fri Sep 4 09:43:48 UTC 2015
Hi everybody!
With the code at the end of this mail I would have expected an outcome
similar to this one
R: T , E: T - [REFUSED TO PRINT]
R: T , E: NIL - [REFUSED TO PRINT]
R: NIL, E: T - #<MY-CONDITION 20098B07>
R: NIL, E: NIL - My condition occured.
because the standard says that "if *PRINT-READABLY* is true, printing
proceeds as if *PRINT-ESCAPE* were also true." This would mean that
the first two lines should look the same because the value of
*PRINT-ESCAPE* is irrelevant in this case. However, while this is
what happens for example with LispWorks, AllegroCL, and CLISP, in some
other Lisps like SBCL, CCL, and ECL the second line looks like the
fourth.
Isn't that wrong? Or is their interpretation of the standard that the
report function is responsible for obeying *PRINT-READABLY*? But how
does that fit with the possibility of using strings for :REPORT?
Thanks,
Edi.
(define-condition my-condition ()
()
(:report "My condition occured."))
(defun test ()
(let ((error (make-condition 'my-condition)))
(dolist (readably '(t nil))
(dolist (escape '(t nil))
(format t "~&R: ~3A, E: ~3A - " readably escape)
(handler-case
(write error :readably readably :escape escape)
(print-not-readable ()
(write-string "[REFUSED TO PRINT]")))))))
More information about the pro
mailing list