Skip to content

Commit ec71f76

Browse files
authored
Merge pull request #1407 from clasp-developers/unreadable
Cleanup some print-unreadable-object uses
2 parents 271276d + 18d51e7 commit ec71f76

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

RELEASE_NOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Version 2.2.0 (LLVM14) Pending
2+
3+
## Fixes
4+
* Ensure that `print-unreadable-object` can accept output stream designators.
5+
16
# Version 2.1.0 (LLVM14) 2023-01-01
27

38
## Added

src/core/lispStream.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5071,12 +5071,12 @@ void writeln_bf_stream(const std::string& fmt, T_sp strm)
50715071

50725072
CL_LAMBDA(oject stream);
50735073
CL_DECLARE();
5074-
CL_DOCSTRING("Write the address of an object to the stream.");
5074+
CL_DOCSTRING("Write the address of an object to the stream designator.");
50755075
DOCGROUP(clasp);
50765076
CL_DEFUN void core__write_addr(T_sp x, T_sp strm) {
50775077
stringstream ss;
50785078
ss << (void *)x.raw_();
5079-
writestr_stream(ss.str().c_str(), strm);
5079+
writestr_stream(ss.str().c_str(), coerce::outputStreamDesignator(strm));
50805080
}
50815081

50825082
static cl_index

src/lisp/kernel/clos/print.lisp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,13 @@ printer and we should rather use MAKE-LOAD-FORM."
201201
instance)
202202

203203
(defmethod print-object ((class class) stream)
204-
(print-unreadable-object (class stream)
205-
(let ((*package* (find-package "CL")))
206-
(format stream "The ~S ~S"
207-
(class-name (si:instance-class class)) (class-name class))))
204+
(print-unreadable-object (class stream :type t)
205+
(write (class-name class) :stream stream))
208206
class)
209207

210208
(defmethod print-object ((gf standard-generic-function) stream)
211209
(print-unreadable-object (gf stream :type t)
212-
(prin1 (generic-function-name gf) stream))
210+
(write (generic-function-name gf) :stream stream))
213211
gf)
214212

215213
(defmethod print-object ((m standard-method) stream)

src/lisp/kernel/lsp/iolib.lisp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,15 @@ the one defined in the ANSI standard. *print-base* is 10, *print-array* is t,
323323
(cond (*print-readably*
324324
(error 'print-not-readable :object object))
325325
(t
326-
(write-string "#<" stream)
327-
(print-unreadable-object-contents object stream type identity body)
328-
(write-char #\> stream)))
326+
(let ((stream (cond ((null stream)
327+
*standard-output*)
328+
((eq t stream)
329+
*terminal-io*)
330+
(t
331+
stream))))
332+
(write-string "#<" stream)
333+
(print-unreadable-object-contents object stream type identity body)
334+
(write-char #\> stream))))
329335
nil)
330336

331337
(defmacro print-unreadable-object ((object stream &key type identity) &body body)

src/lisp/kernel/lsp/pprint.lisp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,13 @@
12241224
(pprint-logical-block (stream nil :prefix "#<" :suffix ">")
12251225
(print-unreadable-object-contents object stream type identity body)))
12261226
(t
1227-
(write-string "#<" stream)
1228-
(print-unreadable-object-contents object stream type identity body)
1229-
(write-char #\> stream)))
1227+
(let ((stream (cond ((null stream)
1228+
*standard-output*)
1229+
((eq t stream)
1230+
*terminal-io*)
1231+
(t
1232+
stream))))
1233+
(write-string "#<" stream)
1234+
(print-unreadable-object-contents object stream type identity body)
1235+
(write-char #\> stream))))
12301236
nil)

0 commit comments

Comments
 (0)