Next: Output, Previous: Ports, Up: Input and output [Index]
If port is omitted from any input procedure, it defaults to the
value returned by (current-input-port)
. It is an error to
attempt an input operation on a closed port.
The read
procedure converts external representations of Scheme
objects into the objects themselves. That is, it is a parser for the
non-terminal ⟨datum⟩ (see External representations and Pairs and lists). It returns the
next object parsable from the given textual input port, updating
port to point to the first character past the end of the external
representation of the object.
Implementations may support extended syntax to represent record types or other types that do not have datum representations.
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 that
satisfies read-error?
is signaled.
Returns the next character available from the textual input port, updating the port to point to the following character. If no more characters are available, an end-of-file object is returned.
Returns the next character available from the textual input port, but without updating the port to point to the following character. If no more characters are available, an end-of-file object is returned.
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.
Returns the next line of text available from the textual input port, updating the port to point to the following character. If an end of line is read, a string containing all of the text up to (but not including) the end of line is returned, and the port is updated to point just past the end of line. If an end of file is encountered before any end of line is read, but some characters have been read, a string containing those characters is returned. If an end of file is encountered before any characters are read, an end-of-file object is returned. For the purpose of this procedure, an end of line consists of either a linefeed character, a carriage return character, or a sequence of a carriage return character followed by a linefeed character. Implementations may also recognize other end of line characters or sequences.
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
.
Returns an end-of-file object, not necessarily unique.
Returns #t
if a character is ready on the textual 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
.
The char-ready?
procedure 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 removed from the input.
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.
Reads the next k characters, or as many as are available before the end of file, from the textual input port into a newly allocated string in left-to-right order and returns the string. If no characters are available before the end of file, an end-of-file object is returned.
Returns the next byte available from the binary input port, updating the port to point to the following byte. If no more bytes are available, an end-of-file object is returned.
Returns the next byte available from the binary input port, but without updating the port to point to the following byte. If no more bytes are available, an end-of-file object is returned.
Returns #t
if a byte is ready on the binary input port
and returns #f
otherwise. If u8-ready?
returns #t
then the next read-u8
operation on the given port is
guaranteed not to hang. If the port is at end of file then
u8-ready?
returns #t
.
Reads the next k bytes, or as many as are available before the end of file, from the binary input port into a newly allocated bytevector in left-to-right order and returns the bytevector. If no bytes are available before the end of file, an end-of-file object is returned.
Reads the next end - start bytes, or as many as are available before the end of file, from the binary input port into bytevector in left-to-right order beginning at the start position. If end is not supplied, reads until the end of bytevector has been reached. If start is not supplied, reads beginning at position 0. Returns the number of bytes read. If no bytes are available, an end-of-file object is returned.
Next: Output, Previous: Ports, Up: Input and output [Index]