get-char, read-char - read a character from a textual input port
(import (rnrs)) ;R6RS
(import (rnrs io ports)) ;R6RS
(import (rnrs io simple)) ;R6RS, read-char
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
(get-char textual-input-port) ;R6RS only
blocking as necessary until a character is available from
or the data that are available cannot be the prefix of any valid
encoding, or an end of file is reached.
If a complete character is available before the next end of file, that
character is returned, and the input port is updated to point past
that character. If an end of file is reached before any data are read,
the end-of-file object is returned.
is omitted, it defaults to the value returned by
Returns a single value; a character or an end-of-file object.
There is a single, unique end-of-file object.
(let lp ()
(let ((c (read-char)))
(unless (eof-object? c)
(write-char (char-upcase c))
Except for differences in the supported character set and in how
errors are handled, this procedure works the same everywhere.
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
- &i/o-decoding (R6RS)
The port's transcoder is in raise mode and it encountered an invalid
- &i/o-read (R6RS)
There was an I/O error during the read operation.
- &i/o-port (R6RS)
This condition specifies the port object related to an
The assertions described above are errors.
Implementations may signal an error, extend the procedure's
domain of definition to include such arguments,
or fail catastrophically.
is new for the reworked I/O in R6RS.
procedure first appeared in R2RS.
Scheme prior to this, running on MacLISP, had the
LISP 1.5 had the subroutines
for reading characters from punched cards.
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
Markup created by unroff 1.0sc, March 04, 2023.