Page 349 Table of Contents Index Page 351
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E



APPENDIX C. COMMON LISP STREAMS


C.2 Basic Stream Functions

These generic functions must be defined for all stream classes.

=> stream-element-type stream [Generic Function]
This existing Common Lisp function is made generic, but otherwise behaves the same. Class
fundamental-character-stream provides a default method that returns character.

=> open-stream-p stream [Generic Function]
This function is made generic. A default method is provided by class fundamental-stream that
returns true if close has not been called on the stream.

=> close stream &key abort [Generic Function]
The existing Common Lisp function close is redefined to be a generic function, but otherwise
behaves the same. The default method provided by the class fundamental-stream sets a flag
used by open-stream-p. The value returned by close will be as specified by the X3J13 issue
closed-stream-operations.

=> stream-pathname stream [Generic Function]
=> stream-truename stream [Generic Function]
These are used to implement pathname and truename. There is no default method since these
are not valid for all streams.

C.3 Character Input

A character input stream can be created by defining a class that includes fundamental-character-
input-stream
and defining methods for the generic functions below.

=> stream-read-char stream [Generic Function]
Reads one character from stream, and returns either a character object or the symbol :eof if the
stream is at end-of-file. There is no default method for this generic function, so every subclass
of fundamental-character-input-stream must define a method.

=> stream-unread-char stream character [Generic Function]
Undoes the last call to stream-read-char, as in unread-char, and returns nil. There is
no default method for this, so every subclass of fundamental-character-input-stream must
define a method.

=> stream-read-char-no-hang stream [Generic Function]
Returns either a character, or nil if no input is currently available, or :eof if end-of-file is
reached. This is used to implement read-char-no-hang. The default method provided by


Page 349 Table of Contents Index Page 351
Chapters
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30
A, B, C, D, E