CSE 341 - Running MIT Scheme

Instructional Linux Machines

MIT Scheme is available on the instructional linux machines (ceylon, fiji, sumatra, tahiti). 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.

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, start up emacs first. 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.