ToC DocOverview CGDoc RelNotes Index PermutedIndex
Allegro CL
Home Previous Up Next Table of Contents Index
  ANSI Common Lisp   22 Printer   22.4 Dictionary of Printer

22.4.5 pprint-fill, pprint-linear, pprint-tabular Function

pprint-fill stream object &optional colon-p at-sign-p    nil

pprint-linear stream object &optional colon-p at-sign-p    nil

pprint-tabular stream object &optional colon-p at-sign-p tabsize    nil

Arguments and Values:
stream - an output stream designator.

object - an object.

colon-p - a generalized boolean. The default is true.

at-sign-p - a generalized boolean. The default is implementation-dependent.

tabsize - a non-negative integer. The default is 16.

The functions pprint-fill, pprint-linear, and pprint-tabular specify particular ways of pretty printing a list to stream. Each function prints parentheses around the output if and only if colon-p is true. Each function ignores its at-sign-p argument. (Both arguments are included even though only one is needed so that these functions can be used via ~/.../ and as set-pprint-dispatch functions, as well as directly.) Each function handles abbreviation and the detection of circularity and sharing correctly, and uses write to print object when it is a non-list.

If object is a list and if the value of *print-pretty* is false, each of these functions prints object using a minimum of whitespace, as described in Section Printing Lists and Conses. Otherwise (if object is a list and if the value of *print-pretty* is true):

Evaluating the following with a line length of 25 produces the output shown.

(progn (princ "Roads ") 
       (pprint-tabular *standard-output* '(elm main maple center) nil nil 8))
Roads ELM     MAIN

Side Effects:
Performs output to the indicated stream.

Affected By:
The cursor position on the indicated stream, if it can be determined.

The function pprint-tabular could be defined as follows:

(defun pprint-tabular (s list &optional (colon-p t) at-sign-p (tabsize nil))
  (declare (ignore at-sign-p))
  (when (null tabsize) (setq tabsize 16))
  (pprint-logical-block (s list :prefix (if colon-p "(" "")
                                :suffix (if colon-p ")" ""))
    (loop (write (pprint-pop) :stream s)
          (write-char #\Space s)
          (pprint-tab :section-relative 0 tabsize s)
          (pprint-newline :fill s))))

Note that it would have been inconvenient to specify this function using format, because of the need to pass its tabsize argument through to a ~:T format directive nested within an iteration over a list.

Allegro CL Implementation Details:

Home Previous Up Next Table of Contents Index
© Franz Inc. 1998-2015 - File last updated 03-23-2015