Getting started with Scheme

Here are a few handy links:

whuang@cs.rpi.edu; email
Last update: September 4, 2001


About MIT Scheme and Dr. Scheme

I am recommending two Scheme implementations to you: MIT Scheme and Dr. Scheme. I will only be supporting MIT Scheme in the long run, so you should plan on using MIT Scheme at least by Assignment 3. The only reason I am telling you about Dr. Scheme is that it is probably easier to get started with Dr. Scheme because it gives better error messages. Your code will be tested under the latest version of MIT Scheme (7.5.17), so it must run under MIT Scheme!

For many assignments (but probably not the first two), I will provide support code so that you don't have to do the "grunge work" in implementing a system. I often provide this support code in compiled form which will be specific to MIT Scheme.

The latest version of MIT Scheme is available only for x86 hardware but for a variety of operating systems (Linux, FreeBSD, Windows, etc.). Version 7.3 is available for other hardware platforms. For the level of Scheme that we'll be using, there isn't much difference between 7.3 and 7.5. I'd prefer that everyone use version 7.5 if possible. Let me know if you are using version 7.3.

Dr. Scheme is available for Linux, Solaris, MacOS, and Windows.

Getting and Dr. Scheme

You can download Dr. Scheme from the Dr. Scheme home page. If you're using Dr. Scheme on a windows box, you might want gnu-emacs for windows (also see the gnu-emacs for windows FAQ .

Getting and running MIT Scheme

You can download the latest version of MIT Scheme from the the MIT Scheme Release 7.5 home page. A note for Linux users: although it says it is for a 2.2 kernel, I have been running version 7.5.16 just fine on my RedHat 7.1 machine.

There are also installation instructions on this page. (Actually, it just points you to Chapter 2 of the User manual.)

There are three basic ways you can run MIT Scheme (in order of my recommendation):

  1. Run MIT Scheme as an inferior process under gnu-emacs or xemacs. (This option is not available under Windows.)
  2. Run Edwin, the emacs-like editor that comes with MIT Scheme.
  3. Run MIT Scheme standalone.

I do not recommend running MIT Scheme standalone because you have no command line editing. And besides, I strongly recommend using emacs or Edwin to write your code, so why not run scheme via one of these methods?

Running Scheme under gnu-emacs

If you want to run Scheme as an inferior process in gnu-emacs or xemacs (this is not an option on Windows machines), then you'll need to download either the xscheme.elxscheme.el or xscheme.elcxscheme.elc files. You'll have to put them in the appropriate place on your system. On my RedHat Linux 7.1 system, this is in /usr/share/emacs/20.7/lisp.

You can either do a M-x load-library and type xscheme at the prompt, or you can add the following line to your .emacs file: (load-library "xscheme") Then, the command M-x run-scheme will bring up a Scheme interaction buffer with an inferior Scheme process. For more information on using MIT Scheme with emacs:

Running Edwin

Windows users actually have it easy: they can simply use the shortcuts in the Start menu. In UNIX, you need to give the command:

scheme -edwin -edit
On my computer, I have aliased edwin to the above command.

To get the Edwin tutorial, type "C-h i" (i.e. control-h followed by the letter "i"). To exit Edwin, type "C-x C-c". For more information on using Edwin:

One customization that I recommend for Edwin is creating a .edwin file that contains the following line: (define-key 'scheme #\m-q 'fill-paragraph) This will bind the M-q to the fill-paragraph command. This is useful for reflowing your comments into proper paragraphs. It knows about the Scheme comment character (a semicolon) and can deal with multiple comment characters (i.e. three semicolons at the beginning of a line to start comments).

Running Scheme standalone

You can run scheme all by itself, write your code in some editor (preferrably emacs), and then load your code via the command:
(load "filename.scm")
But again, I don't recommend this option.

MIT Scheme on CS machines

When you get your CS account, you can run MIT Scheme (version 7.3) on the Solaris 8 Suns in the CS department.

You can access the CS department machines via "ssh" to remote.cs.rpi.edu which will route you to a machine. You could also go to the SPARC lab in Amos Eaton 217 or the OOT lab in Amos Eaton 119 (?).

Edwin will not run on the CS machines for some reason, so you should run Scheme as an inferior process of emacs or xemacs. Not all the keybindings below will work for version 7.3, though perhaps it just means that the xscheme.elc file needs to be updated.

If you have some way of running version 7.5, I'd suggest that instead.

Top 10 keybindings in Edwin/Emacs for MIT Scheme

These are keybindings specific to using MIT Scheme. I STRONGLY recommend that you spend some time learning how to use the emacs editor itself, i.e. learn the basic keybindings for moving the cursor around, switching buffers, killing and yanking text, etc. The time you spend will be more than repaid in your productivity.

  1. TAB properly indents your scheme code

    Type a line of code. Hit return. Hit TAB. Type the next line of code. Repeat.

    OR, put the cursor an any point on a line of improperly indented code. Hit TAB, and the line will be indented the proper amount (relative to the lines above it, so start at the top if you need to do multiple lines, or use C-M-q).

  2. C-x C-e sends the expression to the left of the cursor. This works both in the Scheme interaction buffer as well as in scheme-mode buffers where you are editing your code.

    This command looks left from the cursor until it has a complete expression and then sends that to the Scheme interpreter.

  3. M-z sends the current expression to the Scheme interpreter. This works both in the Scheme interaction buffer as well as in scheme-mode buffers where you are editing your code.

    This command looks for an open parenthesis in the leftmost column and sends all the text from there up to the cursor position, and then to the right of the cursor until all parentheses are balanced.

  4. C-c C-s when done in a scheme-mode buffer, will switch to the Scheme interaction buffer.

  5. M-p and M-n in the Scheme interaction buffer will scroll through the history of expressions that you have sent to the Scheme interpreter. (This doesn't work if you are using version 7.3. You can use C-c C-y to yank the previous command.)

  6. C-c C-c sends an interrupt to the Scheme interpreter.

  7. M-o from a scheme-mode buffer, will send the entire buffer to the Scheme interpreter.

  8. C-M-f and C-M-b move the cursor over the previous and next (respectively) parenthesis balanced list. (C-M-p and C-M-n perform the same functions.)

  9. C-M-a and C-M-e move the cursor to the beginning and end of a definition, respectively.

    Your code should be indented properly for these to have the desired effect.

  10. C-M-q properly indents an entire definition.

    The cursor should be on the opening parenthesis of the define for this to work properly.