Previous: stdlib io port, Up: stdlib io [Index]
This section describes the (rnrs io simple (6))
library, which
provides a somewhat more convenient interface for performing textual I/O
on ports. This library implements most of the I/O procedures of the
previous revision of this report.
The ports created by the procedures of this library are textual ports associated implementation–dependent transcoders.
These are the same as eof-object
and eof-object?
from the
(rnrs io ports (6))
library.
proc should accept one argument.
These procedures open the file named by filename for input or for output, with no specified file options, and call proc with the obtained port as an argument.
If proc returns, the port is closed automatically and the values returned by proc are returned.
If proc does not return, the port is not closed automatically, unless it is possible to prove that the port will never again be used for an I/O operation.
These are the same as the input-port?
and output-port?
procedures in the (rnrs io ports (6))
library.
These are the same as the current-input-port
,
current-output-port
, and current-error-port
procedures
from the (rnrs io ports (6))
library.
thunk must be a procedure and must accept zero arguments.
The file is opened for input or output using empty file options, and thunk is called with no arguments.
During the dynamic extent of the call to thunk, the obtained port
is made the value returned by current-input-port
or
current-output-port
procedures; the previous default values are
reinstated when the dynamic extent is exited.
When thunk returns, the port is closed automatically. The values returned by thunk are returned.
If an escape procedure is used to escape back into the call to thunk after thunk is returned, the behavior is unspecified.
Open filename for input, with empty file options, and return the obtained port.
Open filename for output, with empty file options, and return the obtained port.
Close input-port or output-port, respectively.
Reads from textual-input-port, blocking as necessary until a character is available, or the data that is 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:
read-char
returns that character and updates the input port to
point past that character.
If an end of file is reached before any data are read: read-char
returns the end–of–file object.
If textual-input-port is omitted, it defaults to the value
returned by current-input-port
.
This is the same as read-char
, but does not consume any data from
the port.
Read an external representation from textual-input-port and return the datum it represents.
The read
procedure operates in the same way as get-datum
.
If textual-input-port is omitted, it defaults to the value
returned by current-input-port
.
Write an encoding of the character char to the textual-output-port, and return unspecified values.
If textual-output-port is omitted, it defaults to the value
returned by current-output-port
.
This is equivalent to using write-char
to write #\linefeed
to textual-output-port.
If textual-output-port is omitted, it defaults to the value
returned by current-output-port
.
Write a representation of obj to the given textual-output-port.
Strings that appear in the written representation are not enclosed in doublequotes, and no characters are escaped within those strings.
Character objects appear in the representation as if written by
write-char
instead of by write
.
The display
procedure returns unspecified values.
The textual-output-port argument may be omitted, in which case it
defaults to the value returned by current-output-port
.
Write the external representation of obj to textual-output-port.
The write
procedure operates in the same way as put-datum
.
If textual-output-port is omitted, it defaults to the value
returned by current-output-port
.
Previous: stdlib io port, Up: stdlib io [Index]