Many Scheme programs avoid explicit input and output operations, obtaining input via direct function calls in the interactions window, and producing output by returning values. Other Scheme programs explicitly print output for the user during evaluation using write or display, or explicitly request input from the user using read or read-char.
Explicit input and output appear in the interactions window, but within special boxes that separate explicit I/O from normal expressions and results. For example, evaluating
> (read)in the interactions window produces a special box for entering input:
(The underscore indicates the location of the flashing caret.) Type an number into the box and hit Enter, and that number becomes the result of the (read) expression. If you type 5, the overall interaction appears as follows:![]()
> (read)5 > _
The mouse cursor becomes a watch whenever DrScheme is evaluating expression, but you can still use the mouse to move the selection in an input box.
Output goes to the same box as input. If you execute the program
(define v (read))
(display v)
v
and provide the input S-expression (1 2), the interactions window
ultimately appears as follows:
In this example, display produces output immediately beneath the
input you typed, but the final result was printed outside the box
because it is the result of the program, rather than explicit
output. (The above example assumes constructor-style printing. With
traditional value printing, the final line outside the box would be
(1 2).)
(cons 1 (cons 2 empty)))
> _
Entering the same program line-by-line in the interactions window
produces a different-looking result:
> (define v (read))
Although it is the same program as before, entering the program
expression-by-expression demonstrates how each prompt creates its
own I/O box.
> (display v)
> v
(cons 1 (cons 2 empty))
> _