Next: , Previous: , Up: Streams   [Contents][Index]


5.24.4 Output Functions

Function: write stream data #!optional length

Writes the specified character(s) to the output stream stream. data is either the character or the string to be written. If data is a string the optional argument length may specify how many characters are to be written. The value returned is the number of characters successfully written.

(write standard-output "Testing 1.. 2.. 3..")
    -| Testing 1.. 2.. 3..
    ⇒ 19
Function: copy-stream input-stream output-stream

This function copies all characters which may be read from input-stream to output-stream. The copying process is not stopped until the end of the input stream is read. Returns the number of characters copied.

Be warned, if you don’t choose the streams carefully you may get a deadlock which only an interrupt signal can break!

Function: print object #!optional stream

Outputs a newline character to the output stream stream, then writes a textual representation of object to the stream.

If possible, this representation will be the read syntax of object.

object is returned.

(print '(1 2 3))
    -|
    -| (1 2 3)
    ⇒ (1 2 3)
Function: prin1 object #!optional stream

Similar to print but no initial newline is output.

(prin1 '(1 2 3))
    -| (1 2 3)
    ⇒ (1 2 3)

(prin1 '|(xy((z]|)              ;A strange symbol
    -| \(xy\(\(z\]
    ⇒ \(xy\(\(z\]
Function: prin1-to-string object

Returns a string containing the characters that prin1 would output when it prints object.

(prin1-to-string '(1 2 3))
    ⇒ "(1 2 3)"
Function: princ object #!optional stream

Prints a textual representation of object to the output stream stream. No steps are taken to create output that read can parse; in particular, no double-quote characters surround strings.

(princ "foo")
    -| foo
    ⇒ "foo"

(princ '|(xy((z]|)
    -| (xy((z]
    ⇒ \(xy\(\(z\]

Several variables may be used to control how objects are printed.

Variable: print-escape

This defines which control characters print and prin1 will escape (using backslashes). Possible values are:

()

Only escape double-quote and backslash characters.

newlines

Only escape double-quote, backslash, newline, TAB, and formfeed characters.

t

Escape double-quote, backslash, and all control characters (anything with a numeric value less than 32, or greater than 126).

Variable: print-length

This variable, if true, limits the number of elements printed from lists.

Variable: print-level

This variable, if true, limits the recursion depth when printing lists.


Next: , Previous: , Up: Streams   [Contents][Index]