From 2f94737a4ef20fe9dc36bd3e49a4bf19e246c571 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 11 May 2006 14:04:54 +0100 Subject: [PATCH] show: Handle multiple values correctly. While we're at it, make sure the output is pretty-printed in an attractive way, and print semicolons down the left hand side to protect any weird characters which appear from messing up the REPL state. --- mdw-base.lisp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mdw-base.lisp b/mdw-base.lisp index 59ea692..37a3068 100644 --- a/mdw-base.lisp +++ b/mdw-base.lisp @@ -53,11 +53,17 @@ (defun ,name ,args ,@body))) (defmacro show (x) - "Debugging tool: print the expression X and its value." + "Debugging tool: print the expression X and its values." (let ((tmp (gensym))) - `(let ((,tmp ,x)) - (format t "~&~S: ~S~%" ',x ,tmp) - ,tmp))) + `(let ((,tmp (multiple-value-list ,x))) + (format t "~&") + (pprint-logical-block (*standard-output* nil :per-line-prefix ";; ") + (format t + "~S = ~@_~:I~:[#~;~:*~{~S~^ ~_~}~]" + ',x + ,tmp)) + (terpri) + (values-list ,tmp)))) (defun stringify (str) "Return a string representation of STR. Strings are returned unchanged; -- 2.11.0