0.8.6.32:
authorChristophe Rhodes <csr21@cam.ac.uk>
Mon, 8 Dec 2003 11:28:21 +0000 (11:28 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Mon, 8 Dec 2003 11:28:21 +0000 (11:28 +0000)
Fix for (pprint '`(lambda ,x)) bug
... PPRINT-LAMBDA-LIST needs to be aware of our backquote
implementation

NEWS
package-data-list.lisp-expr
src/code/backq.lisp
src/code/pprint.lisp
tests/pprint.impure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index a7342ad..c10435b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2202,6 +2202,9 @@ changes in sbcl-0.8.7 relative to sbcl-0.8.6:
   * bug fix: buffered :DIRECTION :IO streams are less likely to become
     confused about their position.  (thanks to Adam Warner and Gerd 
     Moellmann)
+  * bug fix: Pretty printing backquoted forms with unquotations in the
+    argument list position of various code constructs such as LAMBDA
+    now works correctly.  (reported by Paul Dietz)
   * optimization: performance of string output streams is now less
     poor for multiple small sequence writes.
   * ASDF-INSTALL bug fix: now parses *PROXY* properly.  (thanks to
index 0ff5146..c8fac48 100644 (file)
@@ -932,6 +932,10 @@ retained, possibly temporariliy, because it might be used internally."
              "PREPARE-FOR-FAST-READ-BYTE"
              "PREPARE-FOR-FAST-READ-CHAR"
 
+            ;; reflection of our backquote implementation that the
+            ;; pprinter needs
+            "*BACKQ-TOKENS*"
+            
             ;; hackery to help set up for cold init
              "!BEGIN-COLLECTING-COLD-INIT-FORMS"
             "!COLD-INIT-FORMS"
index 32cbdcf..8393141 100644 (file)
   (set-macro-character #\, #'comma-macro))
 #+sb-xc-host (!backq-cold-init)
 
+;;; The pretty-printer needs to know about our special tokens
+(defvar *backq-tokens*
+  '(backq-comma backq-comma-at backq-comma-dot backq-list
+    backq-list* backq-append backq-nconc backq-cons backq-vector))
+
 (/show0 "done with backq.lisp")
index d17ccfc..32df69b 100644 (file)
 
 (defun pprint-lambda-list (stream lambda-list &rest noise)
   (declare (ignore noise))
+  (when (and (consp lambda-list)
+            (member (car lambda-list) *backq-tokens*))
+    ;; if this thing looks like a backquoty thing, then we don't want
+    ;; to destructure it, we want to output it straight away.  [ this
+    ;; is the exception to the normal processing: if we did this
+    ;; generally we would find lambda lists such as (FUNCTION FOO)
+    ;; being printed as #'FOO ]  -- CSR, 2003-12-07
+    (output-object lambda-list stream)
+    (return-from pprint-lambda-list nil))
   (pprint-logical-block (stream lambda-list :prefix "(" :suffix ")")
     (let ((state :required)
          (first t))
index 8423f9f..32451be 100644 (file)
           (write '`(,  ?foo) :stream s :pretty t :readably t))
         "`(,?FOO)"))
 
+;;; bug reported by Paul Dietz on sbcl-devel: unquoted lambda lists
+;;; were leaking the SB-IMPL::BACKQ-COMMA implementation.
+(assert (equal
+        (with-output-to-string (s)
+          (write '`(foo ,x) :stream s :pretty t :readably t))
+        "`(FOO ,X)"))
+(assert (equal
+        (with-output-to-string (s)
+          (write '`(foo ,@x) :stream s :pretty t :readably t))
+        "`(FOO ,@X)"))
+#+nil ; '`(foo ,.x) => '`(foo ,@x) apparently. 
+(assert (equal
+        (with-output-to-string (s)
+          (write '`(foo ,.x) :stream s :pretty t :readably t))
+        "`(FOO ,.X)"))
+(assert (equal
+        (with-output-to-string (s)
+          (write '`(lambda ,x) :stream s :pretty t :readably t))
+        "`(LAMBDA ,X)"))
+(assert (equal
+        (with-output-to-string (s)
+          (write '`(lambda ,@x) :stream s :pretty t :readably t))
+        "`(LAMBDA ,@X)"))
+#+nil ; see above
+(assert (equal
+        (with-output-to-string (s)
+          (write '`(lambda ,.x) :stream s :pretty t :readably t))
+        "`(LAMBDA ,.X)"))
+(assert (equal
+        (with-output-to-string (s)
+          (write '`(lambda (,x)) :stream s :pretty t :readably t))
+        "`(LAMBDA (,X))"))
+\f
 ;;; success
 (quit :unix-status 104)
index 5af4ef9..5638aac 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".)
-"0.8.6.31"
+"0.8.6.32"