User Tools


Function WRITE, PRIN1, PRINT, PPRINT, PRINC

Syntax

  • write object &key array base case circle escape gensym length level lines miser-width pprint-dispatch pretty radix readably right-margin streamobject
  • prin1 object &optional output-streamobject
  • princ object &optional output-streamobject
  • print object &optional output-streamobject
  • pprint object &optional output-stream<no values>

Arguments and Values

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 below table, the corresponding printer control variable is dynamically bound to its value while printing goes on; for each keyword parameter in the below table 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.

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

Exceptional Situations

None.

See Also

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)

\issue{PRETTY-PRINT-INTERFACE} \issue{PRINC-READABLY:X3J13-DEC-91} \issue{PRINC-READABLY:X3J13-DEC-91}