X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fprint.lisp;h=91f200ff52deecdc7cc0b9e56a4cf511dda26ee2;hb=2db3b6b4cb740d5b6512459c223859f747807b09;hp=ac90cfe255ae3e4f23735ef06656634374901767;hpb=148e3820ad314a9b59d0133c1d60eaac4af9118b;p=sbcl.git diff --git a/src/code/print.lisp b/src/code/print.lisp index ac90cfe..91f200f 100644 --- a/src/code/print.lisp +++ b/src/code/print.lisp @@ -973,7 +973,7 @@ (write-char (if (zerop bit) #\0 #\1) stream))) (t (when (and *print-readably* - (not (eq (array-element-type vector) t))) + (not (array-readably-printable-p array))) (error 'print-not-readable :object vector)) (descend-into (stream) (write-string "#(" stream) @@ -1000,6 +1000,14 @@ (when (needs-slash-p char) (write-char #\\ stream)) (write-char char stream)))))) +(defun array-readably-printable-p (array) + (and (eq (array-element-type array) t) + (let ((zero (position 0 (array-dimensions array))) + (number (position 0 (array-dimensions array) + :test (complement #'eql) + :from-end t))) + (or (null zero) (null number) (> zero number))))) + ;;; Output the printed representation of any array in either the #< or #A ;;; form. (defun output-array (array stream) @@ -1016,7 +1024,7 @@ ;;; Output the readable #A form of an array. (defun output-array-guts (array stream) (when (and *print-readably* - (not (eq (array-element-type array) t))) + (not (array-readably-printable-p array))) (error 'print-not-readable :object array)) (write-char #\# stream) (let ((*print-base* 10))