Here are a few handy links:
whuang@cs.rpi.edu; email
Getting and running MIT Scheme
The first thing is to
download the lastest version of MIT Scheme. You can also find
download instructions there which are pretty straightforward.
Note that the documentation (in HTML form) comes with the distribution. Find it, and create a bookmark in your web browser.
There are three basic ways you can run MIT Scheme (in order of my recommendation):
I do not recommend running MIT Scheme standalone because you do not have command line editing. Besides, I strongly recommend using emacs or Edwin to write your code, so you might as well run your code via one of these methods.
If you're using Windows, you don't have the choice of using Scheme through gnu-emacs. However, you may want to download gnu-emacs anyway and use it to edit your code (because it is more user friendly than Edwin) and then using Edwin to run and debug. You can download emacs for Windows from one of the mirrors listed in the Emacs Windows FAQ.
If you're using UNIX of some sort, I suggest using gnu-emacs. Here's a comparison of the advantages and disadvantages of Edwin and gnu-emacs:
Edwin | gnu-emacs |
---|---|
+ scheme editing mode with electric parentheses | + scheme editing mode electric parentheses |
+ M-p and M-n scroll through command history | - Can only yank previous command with C-c C-y |
- Doesn't work with the X-cut buffer | + X-cut buffer can be used to cut and paste between windows |
- Missing some emacs features | + It's real emacs! |
+ Has nice debugging interface | - Text debugging interface |
- No pull down menus | + Pull down menus |
As a gnu-emacs "power user", I find Edwin kind of annoying because
of missing gnu-emacs features, so I work using the gnu-emacs interface
and only use edwin for extended debugging sessions. You may very well
want the (relative) user-friendliness of emacs over Edwin, but if you
know (or are willing to learn) emacs well enough that you don't need
the pull down menus and such, then you may prefer Edwin.
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:
This file should replace the xscheme.elc file that comes with emacs. You'll have to find the appropriate directory on your system. On my Mandrake Linux 8.2 system, this is the directory: /usr/share/emacs/21.1/lisp.
(load-library "xscheme")
To exit emacs, type C-x C-c (that's control-x followed by
control-c).
Running Edwin
In Windows, you can start Edwin by simply using the shortcut from the
Start menu, but in UNIX, you need to give the command:
scheme -edwin -editYou will find it convenient to create an alias. For example, I have added the line:
alias edwin='scheme -edwin -edit'to my ~/.bashrc file.
To exit Edwin, type C-x C-c (that's control-x followed by control-c).
(load "filename.scm")But again, I don't recommend this option.
To exit scheme, type "(exit)".
Here are some other emacs resources you may find useful:
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 for you.
In Edwin, M-p and M-n will take you through the
previous commands sent to the scheme interpreter. In emacs, C-c
C-y will yank the previous command.
Scheme program buffers
When you load a file with the extension .scm, Emacs/Edwin
will enter Scheme mode. There are a number of commands to help you
edit and run scheme code.
The M-z and C-x C-e commands work the same in this buffer as they do in a scheme interaction buffer. The result will be printed in the *scheme* buffer but also briefly displayed under the mode line of the emacs/Edwin window. These commands are useful for sending a single function to Scheme 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.
When typing comments, M-j will act like the return key
except that it will start the next line with the comment character.
In emacs,M-q will reflow a paragraph and
properly comment it. (Edwin can do this too, but see below for how to
set this nondefault keybinding in Edwin.)
For more information
There are a number of other emacs/Edwin commands that you will find useful. Refer to:
(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).
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).
This command looks left from the cursor until it has a complete expression and then sends that to the Scheme interpreter.
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.
Your code should be indented properly for these to have the desired effect.
The cursor should be on the opening parenthesis of the define for this to work properly.