Next: Common Lisp Formatting, Previous: Pathnames and Pathspecs, Up: Common Lisp IO and Formatting [Contents][Index]
A stream
is an object that can be used with an input or output function to
identify an appropriate source or sink of characters or bytes for that
operation.
A stream can be a:
A character stream is a source or sink of characters.
A binary stream is a source or sink of bytes.
A stream can be a/n:
source of data
sink for data
a stream that is both an input and an output stream.
when ‘:direction-probe’ is given to open
A stream associated with a file is either:
an object of class file stream is used to represent a file
stream. The basic operation for opening a file is open
, which typically
returns a file stream. The basic operation for closing a stream is close
.
The macro with-open-file
is useful to express the common idiom of opening a
file for the duration of a given body of code, and assuring that the
resulting stream is closed upon exit from that body.
whose target is a stream associated with a file.
Such streams can be used as pathname designators (see pathname designator).
Normally, when a stream associated with a file is used as a pathname designator, it denotes the pathname used to open the file; this may be, but is not required to be, the actual name of the file.
Some functions, such as truename
and delete-file
, coerce streams to
pathnames in a different way that involves referring to the actual file that
is open, which might or might not be the file whose name was opened originally
(truename function).
Streams are either:
in general, operations that create and return streams return open streams.
the action of closing a stream marks the end of its use as a source or sink of data, permitting the implementation to reclaim its internal data structures, and to free any external resources which might have been locked by the stream when it was opened.
Coercion of streams to pathnames is permissible for closed streams;
Next: Common Lisp Formatting, Previous: Pathnames and Pathspecs, Up: Common Lisp IO and Formatting [Contents][Index]