First we start up Scheme. If we're using RScheme under UNIX, that's probably
by typing rs
at the UNIX %
prompt.
(RScheme might be installed under a different name on your system,
perhaps rscheme
, if so, use that name instead. If you're not using
UNIX, start up RScheme the way you start up any program on your system,
perhaps by clicking on its icon. If you're using UNIX but your shell
has a different prompt, like >
, don't worry about it.
[ Note to my (UT CS)students: on our machines, RScheme is installed
as /p/bin/runscheme
. You can just type that at the UNIX prompt,
or if you have /p/bin
in your path, plain runscheme
will
do. ]
%rs
Now the Scheme system starts up and prints out some information about
itself, usually including including the name and version version number,
and then gives you a Scheme prompt.
We'll pretend that the prompt is Scheme>
, but on your system it's
probably something different. (For RScheme, it's something like
top[0]=>
, where the first few characters give you some information
about the state of the system, and the =>
tells you it's ready
for input.)
Scheme then waits for you to type in an expression and hit <RETURN>
.
(By that I mean hit the "RETURN" or "ENTER" key on the keyboard. In some
Scheme systems, these may be distinct keys, and you may have to hit "ENTER";
the documentation for your system will tell you which key does what.)
Scheme lets you type, echoing the characters to the screen, and doesn't
do anything else until you hit <RETURN>
. Until you hit <RETURN>
,
you can back up to correct typing mistakes (just as you can in an operating
system's command shell), using the delete or backspace key.
Now type in a variable definition (define myvar 10)
, and hit
<RETURN>
.
What's happening on the screen looks something like this.
Generational Real-Time Garbage Collector Version 0.5 RScheme version 0.7 Scheme>(define myvar 10) #void Scheme>
Here we defined a variable named myvar
, giving it the initial
value 10
. Scheme read what we typed and figured out what it meant,
and then allocated some storage for the variable binding, and initialized
that storage with (a pointer to) 10
. Scheme keeps track of the
fact that the storage it allocated is now known as myvar
, as well
as keeping track of the value in it.
What Scheme prints out after evaluating this expression may be different
on your system (you may not see #void
). That's because the Scheme
standard doesn't specify what's returned as the value of a definition
expression. (It's possible that your Scheme system will print out
something a little more verbose, or different, or nothing at all as the
value of a define
expression. Don't worry about it.)
You don't usually use the result value of a definition--you're just defining something to use later. Depending on the implementation you're using, you'll see whatever the implementors chose to have definitions return. In some systems, a special unusable value is returned, and Scheme will suppress the printing of these meaningless values to avoid clutter on the screen.