(r5rs.info.gz) Input
Info Catalog
(r5rs.info.gz) Ports
(r5rs.info.gz) Input and output
(r5rs.info.gz) Output
6.6.2 Input
-----------
-- library procedure: read
-- library procedure: read port
`Read' converts external representations of Scheme objects into the
objects themselves. That is, it is a parser for the nonterminal
<datum> (see sections External representation and
Pairs and lists). `Read' returns the next object parsable from
the given input PORT, updating PORT to point to the first
character past the end of the external representation of the
object.
If an end of file is encountered in the input before any
characters are found that can begin an object, then an end of file
object is returned. The port remains open, and further attempts
to read will also return an end of file object. If an end of file
is encountered after the beginning of an object's external
representation, but the external representation is incomplete and
therefore not parsable, an error is signalled.
The PORT argument may be omitted, in which case it defaults to the
value returned by `current-input-port'. It is an error to read
from a closed port.
-- procedure: read-char
-- procedure: read-char port
Returns the next character available from the input PORT, updating
the PORT to point to the following character. If no more
characters are available, an end of file object is returned. PORT
may be omitted, in which case it defaults to the value returned by
`current-input-port'.
-- procedure: peek-char
-- procedure: peek-char port
Returns the next character available from the input PORT,
_without_ updating the PORT to point to the following character.
If no more characters are available, an end of file object is
returned. PORT may be omitted, in which case it defaults to the
value returned by `current-input-port'.
_Note:_ The value returned by a call to `peek-char' is the
same as the value that would have been returned by a call to
`read-char' with the same PORT. The only difference is that
the very next call to `read-char' or `peek-char' on that PORT
will return the value returned by the preceding call to
`peek-char'. In particular, a call to `peek-char' on an
interactive port will hang waiting for input whenever a call
to `read-char' would have hung.
-- procedure: eof-object? obj
Returns #t if OBJ is an end of file object, otherwise returns #f.
The precise set of end of file objects will vary among
implementations, but in any case no end of file object will ever
be an object that can be read in using `read'.
-- procedure: char-ready?
-- procedure: char-ready? port
Returns #t if a character is ready on the input PORT and returns
#f otherwise. If `char-ready' returns #t then the next
`read-char' operation on the given PORT is guaranteed not to hang.
If the PORT is at end of file then `char-ready?' returns #t.
PORT may be omitted, in which case it defaults to the value
returned by `current-input-port'.
_Rationale:_ `Char-ready?' exists to make it possible for a
program to accept characters from interactive ports without
getting stuck waiting for input. Any input editors
associated with such ports must ensure that characters whose
existence has been asserted by `char-ready?' cannot be rubbed
out. If `char-ready?' were to return #f at end of file, a
port at end of file would be indistinguishable from an
interactive port that has no ready characters.
Info Catalog
(r5rs.info.gz) Ports
(r5rs.info.gz) Input and output
(r5rs.info.gz) Output
automatically generated byinfo2html