# HG changeset patch # User Steve Losh # Date 1478015465 0 # Node ID b7509448269edf9f895836b11ba4108d6f3f1b8c # Parent d49a710b5fcc34c5eeb13e20b87a39b2785a147d Fix up `print-hash-table` diff -r d49a710b5fcc -r b7509448269e losh.lisp --- a/losh.lisp Tue Nov 01 15:50:54 2016 +0000 +++ b/losh.lisp Tue Nov 01 15:51:05 2016 +0000 @@ -1353,17 +1353,24 @@ (reduce #'max <> :initial-value 0) (clamp 0 20 <>)))) (print-unreadable-object (hash-table stream :type t :identity nil) - (format stream ":test ~A :count ~D {~%~{~{ ~vs ~s~}~%~}}" - (hash-table-test hash-table) - count - (loop - :with limit = 40 - :for key :in keys - :for val :in vals - :for i :from 0 :to limit - :collect (if (= i limit) - (list key-width 'too-many-items (list (- count i) 'more)) - (list key-width key val))))))) + (princ + ;; Something shits the bed and output gets jumbled (in SBCL at least) if + ;; we try to print to `stream` directly in the format statement inside + ;; `print-unreadable-object`, so instead we can just render to a string + ;; and `princ` that. + (format nil ":test ~A :count ~D {~%~{~{ ~vs ~s~}~%~}}" + (hash-table-test hash-table) + count + (loop + :with limit = (or *print-length* 40) + :for key :in keys + :for val :in vals + :for i :from 0 :to limit + :collect + (if (= i limit) + (list key-width :too-many-items (list (- count i) :more)) + (list key-width key val)))) + stream)))) ;;;; Weightlists