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.14 write, prin1, print, pprint, princ Function

Syntax:
write object &keyarray base case circle escape gensym
length level lines miser-width pprint-dispatch
pretty radix readably right-margin stream
   object

prin1 object &optional output-stream    object

princ object &optional output-stream    object

print object &optional output-stream    object

pprint object &optional output-stream    < no values >

Arguments and Values:
object - an object.

output-stream - an output stream designator. The default is standard output.

array - a generalized boolean.

base - a radix.

case - a symbol of type (member :upcase :downcase :capitalize).

circle - a generalized boolean.

escape - a generalized boolean.

gensym - a generalized boolean.

length - a non-negative integer, or nil.

level - a non-negative integer, or nil.

lines - a non-negative integer, or nil.

miser-width - a non-negative integer, or nil.

pprint-dispatch - a pprint dispatch table.

pretty - a generalized boolean.

radix - a generalized boolean.

readably - a generalized boolean.

right-margin - a non-negative integer, or nil.

stream - an output stream designator. The default is standard output.

Description:
write, prin1, princ, print, and pprint write the printed representation of object to output-stream.

write is the general entry point to the Lisp printer. For each explicitly supplied keyword parameter named in the next figure, the corresponding printer control variable is dynamically bound to its value while printing goes on; for each keyword parameter in the next figure that is not explicitly supplied, the value of the corresponding printer control variable is the same as it was at the time write was invoked. Once the appropriate bindings are established, the object is output by the Lisp printer.

Argument correspondences for the WRITE function.
Parameter Corresponding Dynamic Variable
array *print-array*
base *print-base*
case *print-case*
circle *print-circle*
escape *print-escape*
gensym *print-gensym*
length *print-length*
level *print-level*
lines *print-lines*
miser-width *print-miser-width*
pprint-dispatch *print-pprint-dispatch*
pretty *print-pretty*
radix *print-radix*
readably *print-readably*
right-margin *print-right-margin*

prin1, princ, print, and pprint implicitly bind certain print parameters to particular values. The remaining parameter values are taken from *print-array*, *print-base*, *print-case*, *print-circle*, *print-escape*, *print-gensym*, *print-length*, *print-level*, *print-lines*, *print-miser-width*, *print-pprint-dispatch*, *print-pretty*, *print-radix*, and *print-right-margin*.

prin1 produces output suitable for input to read. It binds *print-escape* to true.

princ is just like prin1 except that the output has no escape characters. It binds *print-escape* to false and *print-readably* to false. The general rule is that output from princ is intended to look good to people, while output from prin1 is intended to be acceptable to read.

print is just like prin1 except that the printed representation of object is preceded by a newline and followed by a space.

pprint is just like print except that the trailing space is omitted and object is printed with the *print-pretty* flag non-nil to produce pretty output.

Output-stream specifies the stream to which output is to be sent.

Affected By:
*standard-output*, *terminal-io*, *print-escape*, *print-radix*, *print-base*, *print-circle*, *print-pretty*, *print-level*, *print-length*, *print-case*, *print-gensym*, *print-array*, *read-default-float-format*.

See Also:
readtable-case, Section 22.3.4 FORMAT Printer Operations

Notes:
The functions prin1 and print do not bind *print-readably*.

 (prin1 object output-stream)
==(write object :stream output-stream :escape t)

 (princ object output-stream)
==(write object stream output-stream :escape nil :readably nil)

 (print object output-stream)
==(progn (terpri output-stream)
           (write object :stream output-stream
                         :escape t)
           (write-char #\space output-stream))

 (pprint object output-stream)
==(write object :stream output-stream :escape t :pretty t)

Allegro CL Implementation Details:
See Extensions to cl:write in implementation.htm for information on the Allegro CL implementation of write. Note the links are to the documentation for the current Allegro CL version. Replace /current/ in the URL with the Allegro CL version number to see similar documentation is earlier releases.

Home Previous Up Next Table of Contents Index
© Franz Inc. 1998-2019 - File last updated 02-07-2019