25.  Output  

print-length
print-depth

These variables are defined in the global environment. They control the maximum length and maximum depth, respectively, of a list or vector that is printed. If one of the variables is not bound to an integer, or if its value exceeds a certain, large maximum value (which is at least 2^20), a default value is taken. The default value for print-length is 1000, and the default value for print-depth is 20. Negative values of print-length and print-depth are treated as ``unlimited'', i.e. output is not truncated.

(write obj)
(write obj output-port)

See R^4RS.

(display obj)
(display obj output-port)

See R^4RS.

(write-char char)
(write-char char output-port)

See R^4RS.

(newline)
(newline output-port)

See R^4RS.

(print obj)
(print obj output-port)

If the second argument is omitted, it defaults to the current output port.
Prints obj using write and then prints a newline. print returns void.

(format destination format-string obj ...)

Prints the third and the following arguments according to the specifications in the string format-string. Characters from the format string are copied to the output. When a tilde is encountered in the format string, the tilde and the immediately following character are replaced in the output as follows:

~s
is replaced by the printed representation of the next obj in the sense of write.
~a
is replaced by the printed representation of the next obj in the sense of display.
~~
is replaced by a single tilde.
~%
is replaced by a newline.

An error is signaled if fewer objs are provided than required by the given format string. If the format string ends in a tilde, the tilde is ignored.

If destination is #t, the output is sent to the current output port; if #f is given, the output is returned as a string; otherwise, destination must be an output or input-output port.
Examples:

(format #f "Hello world!")       ==>  "Hello world"
(format #f "~s world!" "Hello")  ==>  "\"Hello\" world"
(format #f "~a world!" "Hello")  ==>  "Hello world"
(format #f "Hello~a")            ==>  "Hello!"
(define (flat-size s)
  (fluid-let ((print-length 1000) (print-depth 100))
    (string-length (format #f "~a" s))))
(flat-size 1.5)                  ==>  3
(flat-size '(a b c))             ==>  7


Markup created by unroff 1.0,    September 24, 1996,    net@informatik.uni-bremen.de