Streams can be capable of input or output (or both), and may deal with characters or with binary elements. The
package provides a number of stream classes with different capabilities from which user defined streams can inherit. In our example the stream must be capable of input and output, and must read characters. The following code defines our stream class appropriately:
((file-stream :initform nil
The new class,
, has fundamental-character-input-stream and fundamental-character-output-stream as its superclasses, which means it inherits the relevant default character I/O methods. We shall be overriding some of these with more relevant and efficient implementations later.
Note that we have also provided a
slot. When making an instance of
we can create an instance of a Common Lisp file stream in this slot. This allows us to use the Common Lisp file stream functionality for reading from and writing to a file.
LispWorks User Guide and Reference Manual - 21 Dec 2011