These are the possible types of input stream, for the functions which use them see section Input Functions.
file
mark
buffer
(buffer . position)
function
nil
if for some reason no character is available.
function should also be able to `unread' one character. When this
happens the function will be called with one argument -- the value of
the last character read. The function should arrange it so that the
next time it is called it returns this character. A possible implementation
could be,
(defvar ms-unread-char nil
"If non-nil the character which was pushed back.")
(defun my-stream (&optional unread-char)
(if unread-char
(setq ms-unread-char unread-char)
(if ms-unread-char
(prog1
ms-unread-char
(setq ms-unread-char nil))
;; Normal case -- read and return a character from somewhere
...
nil
standard-input.
It is also possible to use a string as an input stream. The string to
be read from must be applied to the make-string-input-stream function
and the result from this function used as the input stream.
(read (make-string-input-stream "(1 . 2)"))
=> (1 . 2)
nil.
Go to the first, previous, next, last section, table of contents.