31.6. Generic streams

This interface is CLISP-specific and now obsolete. Please use the Gray streams interface instead.

Generic streams are user programmable streams. The programmer interface:

(gstream:make-generic-stream controller)
returns a generic stream.
(gstream:generic-stream-controller stream)
returns a private object to which generic stream methods dispatch. The typical usage is to retrieve the object originally provided by the user in gstream:make-generic-stream.
(gstream:generic-stream-p stream)
determines whether a stream is a generic stream, returning T if it is, NIL otherwise.

In order to specify the behavior of a generic stream, the user must define CLOS methods on the following CLOS generic functions. The function gstream:generic-stream-x corresponds to the Common Lisp function x. They all take a controller and some number of arguments.

(gstream:generic-stream-read-char controller)
Returns and consumes the next character, NIL at end of file. Takes one argument, the controller object.
(gstream:generic-stream-peek-char controller)
Returns the next character, NIL at end of file. A second value indicates whether the side effects associated with consuming the character were executed: T means that a full READ-CHAR was done, NIL means that no side effects were done. Takes one argument, the controller object.
(gstream:generic-stream-read-byte controller)
Returns and consumes the next integer, NIL at end of file. Takes one argument, the controller object.
(gstream:generic-stream-read-char-will-hang-p controller)
This generic function is used to query the stream's input status. It returns NIL if gstream:generic-stream-read-char and gstream:generic-stream-peek-char will certainly return immediately. Otherwise it returns true.
(gstream:generic-stream-write-char controller char)
The first argument is the controller object. The second argument is the character to be written.
(gstream:generic-stream-write-byte controller by)
The first argument is the controller object. The second argument is the integer to be written.
(gstream:generic-stream-write-string controller string start length)
Writes the subsequence of string starting from start of length length. The first argument is the controller object.
(gstream:generic-stream-clear-input controller)
(gstream:generic-stream-clear-output controller)
(gstream:generic-stream-finish-output controller)
(gstream:generic-stream-force-output controller)
(gstream:generic-stream-close controller)
Take one argument, the controller object.

These notes document CLISP version 2.49.93+Last modified: 2018-02-19