D.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. [annotate]

stream-read-char  stream [Generic Function]
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. [annotate]


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 fundamental-character-input-stream simply calls stream-read-char; this is sufficient for file streams, but interactive streams should define their own method. [annotate]


stream-peek-char  stream [Generic Function]

Returns either a character or :eof without removing the character from the stream's input buffer. This is used to implement peek-char; this corresponds to peek-type of nil. The default method calls stream-read-char and stream-unread-char. [annotate]


stream-listen  stream [Generic Function]

Returns true if there is any input pending on stream, otherwise it returns false. This is used by listen. The default method uses stream-read-char-no-hang and stream-unread-char. Most streams should define their own method since it will usually be trivial and will generally be more efficient than the default method. [annotate]


stream-read-line  stream [Generic Function]

Returns a string as the first value, and t as the second value if the string was terminated by end-of-file instead of the end of a line. This is used by read-line. The default method uses repeated calls to stream-read-char. [annotate]


stream-clear-input  stream [Generic Function]

Clears any buffered input associated with stream, and returns false. This is used to implement clear-input. The default method does nothing. [annotate]