Go to the first, previous, next, last section, table of contents.


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 such that read can turn it into an object structurally similar to object. This will not be possible if object does not have a read syntax.

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 and no quote characters surround strings.

(princ "foo")
    -| foo
    => "foo"

(princ '|(xy((z]|)
    -| (xy((z]
    => \(xy\(\(z\]

Function: format stream template &rest values
Writes to a stream, stream, a string constructed from the format string, template, and the argument values.

If stream is nil the resulting string will be returned, not written to a stream.

template is a string which may contain format specifiers, these are a `%' character followed by another character telling how to print the next of the values. The following options are available

`s'
Write the printed representation of the value without quoting (as if from the princ function).
`S'
Write the printed representation with quoting enabled (like the prin1 function).
`d'
Output the value as a decimal number.
`o'
Write the value in octal.
`x'
In hexadecimal.
`c'
Write the character specified by the value.
`%'
Print a literal percent character. None of the values are used.

The function works through the template a character at a time. If the character is a format specifier (a `%') it inserts the correct string (as defined above) into the output. Otherwise, the character is simply put into the output stream.

If stream isn't nil (i.e. the formatted string is returned) the value of stream is returned.

(format nil "foo %S bar 0x%x" '(x . y) 255)
    => "foo (x . y) bar 0xff"

(format standard-output "The %s is %s!" "dog" "purple")
    -| The dog is purple!
    => #<buffer *jade*>


Go to the first, previous, next, last section, table of contents.