Running Scheme

We will be using MIT Scheme for the programming assignments in this class. Your assignments must run under version 7.3 or 7.4. This page provides information on: FYI, I have stored a copy of the MIT Scheme 7.4 documentation locally:
Last updates: September 23; September 7; September 2, 1999

If you're new to gnu-emacs...

Although you can write Scheme code in any text editor, I highly recommend using gnu-emacs.

If you are not familiar with gnu-emacs, I suggest going through the emacs tutorial. Find RCS UNIX workstation, open up a UNIX window, and type emacs& at the prompt. An emacs window will appear shortly. Type C-h t (that's a control-h followed by the letter t), and it will load the tutorial for you.

See the using emacs section for specific information on using emacs for writing scheme programs.

Using MIT Scheme on RCS

MIT Scheme version 7.3 is available on IBM and SGI UNIX RCS workstations and RCS PCs running Windows NT and 95/98.
UNIX workstations (IBM and SGI)
In order to setup MIT Scheme, type:
setup ~millem/scheme
at the UNIX prompt. See Running Scheme for the different ways you can run scheme.
PCs running windows
Connect to the RCS public area. (Click on the RCS desktop icon, enter your RCS username and password, and select RCS public areas.) Open the "dept", "cs", "ai", "scheme", and "bin" folders. In this last folder, there is edwin.bat and scheme.bat. Click on one of these to load and run the program.

Note that on some computers or in some clusters, it may take some time for Scheme to load. Under a limited test on two computers (W98 box in VCC and NT box in Troy) it can take from 15 seconds to 2 minutes to load!

Downloading MIT Scheme

MIT Scheme version 7.4 (and earlier versions) are freely available for downloading. Version 7.4 runs only on PC platforms; there are versions for several different operating systems. Version 7.3 runs on other platforms.

Go to the Scheme home page and follow the download links as appropriate.

Note: you only need to download the "main binaries" to run MIT Scheme. The "runtime debugging information" and the "Edwin debugging information" may be useful if you spend much time in the debugger.

Note: Under MS Windows, pay heed to the warning that you cannot install this software in a directory whose path name contains spaces (or other unusual characters).

See Running Scheme for the different ways you can run scheme.

Running scheme

There are three basic ways you can run MIT Scheme:
  1. You can run scheme all by itself and load your source code via the command:
    (load "filename.scm")
    but this is tedious, so I don't recommend it.

  2. You can run scheme as an inferior process in gnu-emacs. (Don't know if this works in Windows.)

    You should do M-x load-library, type xscheme at the prompt, and then you can do a M-x run-scheme.

  3. You can use the Edwin interface to MIT Scheme. Edwin is very similar to gnu-emacs but specifically designed for Scheme.

    Windows users actually have it easy: they can simply click on the right icon (though they'll have to edit the shortcut as per the installation directions). In UNIX, you need to give the command:

    scheme -edwin -eval "(edit)"
    Alternatively, you can just start scheme with the command scheme -edwin and then type (edit) at the scheme prompt.
Here are the advantages and disadvantages of Edwin and gnu-emacs:

+ scheme editing mode with electric parentheses + scheme editing mode electiric parentheses
+ M-p and M-n scroll through command history - Can only yank previous command with C-c C-y
- Cannot use fill-paragraph on comments + Can use fill-paragraph on comments
+ Has special debugging modes - Only provides the regular debugger
- Backspace treated at C-h (use delete instead) + Backspace handled properly
- No pull down menus + Pull down menus

I believe the last item is only relevant under X windows. If you don't like using the delete key all the time, you can remap your backspace key to be delete, however, that will probably mess up other programs. I am told that this problem will be fixed in the next release. If you know of another work-around, let me know!

Using Emacs/Edwin with Scheme

Gnu-emacs/Edwin offer many special capabilities for working with Scheme code. This section describes some of the basic commands to interact with Emacs and Edwin. See the User's manual for more details.

Note: For gnu-emacs, this section assumes that you have loaded the xscheme library as described above. If you omit this step, you can still execute the M-x run-scheme command, but this will use a different scheme mode which has some different features. You can add the line (load-library "xscheme") to your .emacs file to have the library loaded automatically every time you start emacs. There are two types of buffers you will use in Edwin/Emacs: a Scheme interaction buffer and a program file buffer.

The Scheme interaction buffer
When you start Edwin, you automatically get a scheme interaction buffer called *scheme*. In gnu-emacs, giving the command M-x run-scheme will start Scheme in a scheme interaction buffer (also called *scheme*). In the Scheme interaction buffer, you can type Scheme expressions and use one of the following commands to send them to the Scheme process to be evaluated:

Experiment with these commands until you understand how to send the expression you want to the Scheme interpreter. If you make an error, you will get a beep and some error messages about calling RESTART. From here, you can get back to the top level of the Scheme interpreter by typing C-c C-c. You can also enter the (regular) debugger by typing (debug). In Edwin, it may offer to start the debugger your you. In Edwin, M-p and M-n will take you through the previous commands sent to the scheme interpreter.

Scheme program buffers
When you load a file with the extension .scm, Emacs/Edwin will enter Scheme mode.

The M-z and C-x C-e commands work the same in this buffer as they do in a scheme interaction buffer (except that the result is printed in the *scheme* buffer). This is useful for sending a single function while you are developing a program.

The M-o command sends the entire buffer to the scheme interpreter.

Emacs/Edwin will indent you code for you: just press tab at the beginning of each line, and the cursor will move to the proper point to begin typing.

Code examples from class

I won't be putting every piece of code I write during class here; only the more lengthy and/or more important examples. Note that these files have a .txt extension so that your web browser doesn't get confused.

Online Scheme reference

I've cached these files locally for now; I'll put up links to where they came from soon.