1 ;;;; printer stuff which has to be defined early (e.g. DEFMACROs)
3 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; This software is derived from the CMU CL system, which was
7 ;;;; written at Carnegie Mellon University and released into the
8 ;;;; public domain. The software is in the public domain and is
9 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
10 ;;;; files for more information.
12 (in-package "SB!IMPL")
14 ;;;; level and length abbreviations
16 (defvar *current-level* 0
18 "The current level we are printing at, to be compared against *PRINT-LEVEL*.
19 See the macro DESCEND-INTO for a handy interface to depth abbreviation.")
21 (defmacro descend-into ((stream) &body body)
23 "Automatically handle *PRINT-LEVEL* abbreviation. If we are too deep, then
24 a # is printed to STREAM and BODY is ignored."
25 (let ((flet-name (gensym)))
26 `(flet ((,flet-name ()
28 (cond ((and (null *print-readably*)
30 (>= *current-level* *print-level*))
31 (write-char #\# ,stream))
33 (let ((*current-level* (1+ *current-level*)))
36 (defmacro punt-print-if-too-long (index stream)
38 "Punt if INDEX is equal or larger then *PRINT-LENGTH* (and *PRINT-READABLY*
39 is NIL) by outputting \"...\" and returning from the block named NIL."
40 `(when (and (not *print-readably*)
42 (>= ,index *print-length*))
43 (write-string "..." ,stream)