CSCI 4150: Introduction to Artificial Intelligence, Fall 2005 |
Running MIT/GNU Scheme
You have two options for running MIT/GNU Scheme:
Installing MIT/GNU Scheme on your own computer
The first thing is to download the lastest
stable version (7.7.1) of MIT/GNU Scheme. Installation
instructions are also available from this web page. MIT/GNU Scheme is
only officially available for x86 *NIX and Windows systems. I believe
some students in previous years have gotten it running on a Mac, but I
don't know any details.
If you have trouble installing MIT/GNU Scheme, one common cause is that your download was corrupted. Either try downloading it again, or check your download against the md5 checksums.
Note that the documentation (in HTML form) comes with the
distribution. Find it and create a bookmark in your web browser.
Running MIT/GNU Scheme from CS machines
MIT/GNU Scheme is installed on all the machines in the
freebsd.remote.cs.rpi.edu pool. You will need to use
ssh (which you can do through SecureCRT) to connect
to these machines.
You will need to use your CS account (which you will be getting if you don't already have one). You can remotely log in to the freebsd.remote pool from any computer on the internet.
You might find it most convenient to log in from a UNIX computer, because you can then X-host windows running on the remote machine. It is possible to do this through Windows, but you're on your own setting it up. You can also run emacs and scheme through a terminal (i.e., text) interface.
There are three ways you can use MIT/GNU Scheme. In order of my recommendation, they are:
I do not recommend running MIT/GNU Scheme standalone because there is no command line editing. Besides, I strongly recommend using emacs or Edwin to write your code, so you might as well run your code through them anyway.
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 http://ftp.gnu.org/gnu/windows/emacs/. (You have your choice of a "bare", regular, or "full" binary.) You may also be interested 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 some debugging sessions. (I usually use text
debugging through gnu-emacs.) 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 (again, 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 system, this is the directory: /usr/share/emacs/21.3/lisp. (This step is not necessary if you are running MIT/GNU Scheme from the CS department machines.)
(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).