1.0.14.0.23: hash-table printing improvements
authorNikodemus Siivola <nikodemus@random-state.net>
Fri, 8 Feb 2008 12:38:15 +0000 (12:38 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Fri, 8 Feb 2008 12:38:15 +0000 (12:38 +0000)
 * Respect printer-control variables when printing readably.

 * Print non-null weakness when printing unreadably.

NEWS
src/code/target-hash-table.lisp
tests/print.impure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index 437d8d2..4e04b0e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,10 @@ changes in sbcl-1.0.15 relative to sbcl-1.0.14:
   * enhancement: implement SB-POSIX:MKTEMP and SB-POSIX:MKDTEMP.
   * SB-DEBUG:PRINT-FRAME-CALL now prints the entry-point kind even
     when SB-DEBUG:*SHOW-ENTRY-POINT-DETAILS* is NIL.
+  * unreadably printed representation of hash-tables now includes
+    weakness if any.
+  * bug fix: readably printing hash-tables now respects other printer
+    control variables.
   * bug fix: compiler gave a bogus STYLE-WARNING for the :SYNCHRONIZED
     keyword with MAKE-HASH-TABLE.
   * bug fix: export SB-POSIX:MKSTEMP.
index 1389875..a5720bc 100644 (file)
@@ -943,16 +943,16 @@ to protect the MAPHASH call."
   (cond ((or (not *print-readably*) (not *read-eval*))
          (print-unreadable-object (hash-table stream :type t :identity t)
            (format stream
-                   ":TEST ~S :COUNT ~S"
+                   ":TEST ~S :COUNT ~S~@[ :WEAKNESS ~S~]"
                    (hash-table-test hash-table)
-                   (hash-table-count hash-table))))
+                   (hash-table-count hash-table)
+                   (hash-table-weakness hash-table))))
         (t
-         (with-standard-io-syntax
-          (format stream
-                  "#.~W"
-                  `(%stuff-hash-table (make-hash-table ,@(%hash-table-ctor-args
+         (write-string "#." stream)
+         (write `(%stuff-hash-table (make-hash-table ,@(%hash-table-ctor-args
                                                           hash-table))
-                                     ',(%hash-table-alist hash-table)))))))
+                                     ',(%hash-table-alist hash-table))
+                :stream stream))))
 
 (def!method make-load-form ((hash-table hash-table) &optional environment)
   (declare (ignore environment))
index 6d8072f..608ce7f 100644 (file)
 ;;; This used to trigger an AVER instead.
 (assert (raises-error? (format t "~>") sb-format:format-error))
 
+;;; readably printing hash-tables, check for circularity
+(let ((x (cons 1 2))
+      (h (make-hash-table))
+      (*print-readably* t)
+      (*print-circle* t)
+      (*read-eval* t))
+  (setf (gethash x h) h)
+  (destructuring-bind (x2 . h2) (read-from-string (write-to-string (cons x h)))
+    (assert (equal x x2))
+    (assert (eq h2 (gethash x2 h2)))))
+
 ;;; success
index ca674a0..5672a63 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.14.22"
+"1.0.14.23"