GNU Info

Info Node: (librep.info)Input Streams

(librep.info)Input Streams


Next: Output Streams Up: Streams
Enter node , (file) or (file)node

Input Streams
-------------

   These are the possible types of input stream, for the functions which
use them see Note: Input Functions.

`FILE'
     Characters are read from the file object FILE, for the functions
     which manipulate file objects see Note: Files.

`FUNCTION'
     Each time an input character is required the FUNCTION is called
     with no arguments. It should return the character read (an
     integer) or false 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 true 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'
     Read from the stream stored in the variable `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.

 - Function: make-string-input-stream string #!optional start
     Returns an input stream which will supply the characters of the
     string STRING in order starting with the character at position
     START (or from position zero if this argument is undefined).

          (read (make-string-input-stream "(1 . 2)"))
              => (1 . 2)

 - Variable: standard-input
     The input stream which is used when no other is specified or is
     false.

   Applications that embed `librep', or dynamically loaded extensions,
may provide further input stream types.


automatically generated by info2www version 1.2.2.9