Summary: We consider ways in which to have Scheme write some output (in addition to generating responses).
Still to be written.
write procedure takes one argument and prints out a
representation of that argument. The nature of the value that it
returns is unspecified (under DrScheme, for instance, it's the
void value) -- the printing is a side effect of the evaluation
of the call to
write, not its result.
DrScheme also encloses the material that
write prints out
inside an interaction box. You can distinguish user input from program
output in an interaction box by its color: User input is displayed in
green, program output in purple. Both are distinguished from DrScheme's
usual way of exhibiting the value of an expression, which is to print it
in dark blue without drawing an interaction box.
> (define my-input (read))
116> my-input 116 > (write my-input) 116
display procedure also takes one argument and prints out a
representation of it, but it differs from
write in that it
does not enclose the representations of strings in double quotation marks
and does not print the mesh-backslash combination when displaying a
> (display "sample string") sample string > (write "sample string") "sample string" > (DISPLAY #\A) A > (write #\A) #\A
newline procedure takes no arguments and returns an
unspecified value; as a side effect, it terminates the current output line.
Successive calls to
produce output that is all strung together on one line. Calls to
newline are used to break up such output into separate lines.
> (begin (display "all-") (display "on-") (display "one-") (display "line") (newline) (display "This is on a ") (display "separate line.") (newline)) all-on-one-line This is on a separate line.
(newline) has exactly the same effect as
(display #\newline), for which you can consider it a
Tuesday, 5 November 2002 [Samuel A. Rebelsky]
Input and output under program control, version of 25 October 2001, available at
I usually create these pages
on the fly, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Tue May 6 09:30:58 2003.
The source to the document was last modified on Mon Mar 3 22:24:11 2003.
This document may be found at