CSE 341 -- Scheme

Running Scheme

Instructional Linux Machines

MIT Scheme is available on the instructional linux machines (ceylon, fiji, sumatra, tahiti).

To use Scheme from a shell, you need to add /cse/courses/misc_lang/linux/mit-scheme/bin to your path (in your .cshrc file). If you don't already have a path, then the line to add is

set path = ($path /cse/courses/misc_lang/linux/mit-scheme/bin)

Now you can type scheme at the shell to get the MIT Scheme interpreter.

A convenient technique is to have one window with a shell running scheme, and another window with your favorite editor. Then you can easily edit and reload programs.

To load your file of Scheme definitions into the interpreter, type (load "file.scm") at the Scheme prompt. If you modify and save your Scheme source file, you should reload it by using the load function again.

If you get an error, you can get back to the top level by typing (restart 1). There are lots of other commands for the debugger -- see the MIT Scheme User Manual.

If you know emacs or are willing to learn it, you will find it more convenient to run scheme under the emacs editor -- see Scheme and Emacs below.

NT Machines

MIT Scheme is available from the instructional NT machines under the Start menu as "Programs --> Server Apps --> MIT Scheme x.x.x". In order to make this alias work, you must map the network drive (if you don't know how to do this, ask support staff) W: from //IFILESRV1/tools.

Once this network drive is mapped, you should run MIT Scheme (Edwin + compiler) from the Start submenu given above. Two windows will pop up, one labeled "Edwin" and one labeled "MIT Scheme". The former is an Emacs-like interactive Scheme editor; be sure to type C-x C-e (Control-x, followed by Control-e) for commands. The latter window is, as far as I can tell, just for debugging messages.

Previous reports that Dr. Scheme (a Scheme development environment) was available on the instructional NT machines appear to be unfounded. If you've figured out where Dr. Scheme lives in the CSE labs, please let us know so we can update this page.

Scheme and Emacs

Emacs has a rather daunting number of keyboard commands, but most users find Emacs a very efficient and flexible environment once they get used to it. It also has reasonable support for Scheme programming. We'll be updating this section as we get more information.

Here is the official documentation for the interface between MIT Scheme and GNU Emacs. If you find the documentation less than wholly accessible, step by step instructions for using Emacs and Scheme on the instructional Linux machines are as follows:

To get Scheme running with Emacs, make sure MIT Scheme is on your path, as above. Then, in Emacs, use C-x C-f (i.e., Control-x followed by Control-f; you can also use the pulldown menu, though that's difficult over telnet) to "find file". Type a filename with a ".scm" extension (yes, you can use tab completion) and hit ENTER. This will load a file, or create a new buffer if no such file exists.

Now, your file should automatically open in Scheme-mode; your mode line should look like this:

----:---F1  new.scm      (Scheme)--L1--All-------------------------

Notice the "(Scheme)" major mode marker. This means that this buffer is now a syntax-sensitive editor for Scheme source code. You can type C-x C-s (Control-x Control-s) to save the file at any time.

Next, you will want to launch a Scheme shell so that you can run a Scheme interpreter. You can do this in a separate telnet window, but it's also possible to run Scheme in a separate Emacs "buffer", as follows:

  1. Type M-x run-scheme. M-x stands for "Meta-X"; on Unix terminal clients, or X-Window versions of Emacs, this is usually ALT-X. Most Windows terminal clients do not properly generate the Meta key (one free client that does is Tera Term) but you can simulate it by pressing Escape.


  2. If MIT Scheme is in your path, this will bring up a buffer whose mode line looks like this:
    ----:**-F1  *scheme*     (Inferior Scheme:run)--L10--All------------
    Unfortunately this will tend to fill the whole screen, but you can fix this by using C-x 2 to split the screen into two parts, and then C-x b buffername to switch one of your windows to the buffer named buffername (which should be the file name that you entered when you did "find file").


  3. Switching between the onscreen buffers can be accomplished by using C-x o (Control-x, followed by a lowercase "o").

To load your file of Scheme definitions into the interpreter, type control-c control-l in either buffer. (The Scheme command (load "file.scm") at the Scheme prompt still works as well.) If you modify and save your Scheme source file, you should reload it by using the load command again. Another useful command is control-x control-e, which evaluates the s-expression just before the cursor.

Kawa: Scheme for the Java Virtual Machine

If you have a Java 1.2-compliant JVM (for example, a recent revision of the Sun JDK), you can run Scheme by downloading and building the Kawa scheme system. For those who are on non-autoconf-capable systems (or, if you just find building your own packages a hassle), I have packaged up the classes as a JAR file:

kawa.jar (588K)

You can download this JAR file and then run the Kawa Scheme interpreter by using the following command from the directory containing the JAR file:

java -classpath ./kawa.jar kawa.repl

If you prefer using a graphical window, use the -w flag, as in:

java -classpath ./kawa.jar kawa.repl -w