Chapter 7. Input/Output

The input/output facilities of RScheme use the concept of a "port". A port is a first-class RScheme object that is passed (implicitly or explicitly) to the input/output functions.

In RScheme, ports come in two varieties, namely input ports which are instances of <input-port> and output ports that are instances of <output-port> [we don't have input output ports?].

While some ports exist when RScheme is started, most have to be created explicitly by an open operation. The open operations thus create ports from other types of objects such as strings that represent file names, or just strings that are themselves used for input or output.

RScheme ports usually buffer input/output for efficiency. This means that you might not see the effect of an output operation immediately. Instead the output may be stored internally in a buffer associated with the port and only written to the underlying device when the buffer is full, or as a result of an explicit flush operation.

When all desired input/output has been accomplished from/to a particular port, you should close the port. Closing the port will free up resources of the operating system and flush the contents of the port.

Input port constructors

Table of Contents
input-port? -- Checks whether an object is a input port.
current-input-port -- Returns the current default input port
open-input-file -- Creates an input port from a file name
with-input-from-file -- Redirect input from file
open-input-process -- Open a port to the output from a shell pipeline.
close-input-port -- Close an input port
read-char -- Read a character
peek-char -- Read a character without consuming it
char-ready? -- Check whether it is safe to read a character
read -- Read an S-expression
output-port? -- Checks whether an object is a output port.
current-output-port -- Returns the current default output port
open-output-file -- Creates an output port from a file name
with-output-to-file -- Redirect output to a file
close-output-port -- Close an output port
open-output-process -- Open a port to the input to a shell pipeline.