Next: Input Stream Functions, Previous: Reading Lines of a File using Standard Input, Up: Streams [Contents][Index]
Some operations may be performed on any kind of stream; the following is a list of standardized operations that are potentially useful with any kind of stream.
close
input-stream-p
output-stream-p
interactive-stream-p
stream-element-type
streamp
with-open-stream
close
closes stream. Closing a stream means that it may no longer be used in
input or output operations. The act of closing a file stream ends the
association between the stream and its associated file; the transaction with
the file system is terminated, and input/output may no longer be performed on
the stream.
a stream (either open or closed).
a boolean with a ‘false’ default value. If abort is ‘true’, an attempt is made to clean up any side effects of having created stream. If stream performs output to a file that was created when the stream was created, the file is deleted and any previously existing file is not superseded.
input-stream-p
returns ‘true’ if stream is an input stream; otherwise, returns
‘false’.
output-stream-p
returns ‘true’ if stream is an output stream; otherwise, returns
‘false’.
Returns ‘true’ if stream is an interactive stream13; otherwise, returns ‘false’.
stream-element-type
returns a type specifier that indicates the types of
objects that may be read from or written to stream. Streams created by open
have an element type restricted to integer or a subtype of type character.
Returns ‘true’ if object is of type stream; otherwise, returns ‘false’.
with-open-stream
performs a series of operations on stream,
returns a value, and then closes the stream. Var is bound to
the value of stream, and then forms are
executed as an implicit progn
.
a variable name; bound to stream.
a form; evaluated to produce a stream. The stream has dynamic extent; its extent ends when the form is exited.
a declare
expression; not evaluated.
an implicit progn
.
the values returned by the forms.
(with-open-stream (s (make-string-input-stream "1 2 3 4")) (+ (read s) (read s) (read s))) => 6
A stream on which it makes sense to perform interactive querying. The general intent of having some streams be classified as interactive streams is to allow them to be distinguished from streams containing batch (or background or command-file) input. Output to batch streams is typically discarded or saved for later viewing, so interactive queries to such streams might not have the expected effect.
Next: Input Stream Functions, Previous: Reading Lines of a File using Standard Input, Up: Streams [Contents][Index]