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.
setup ~millem/schemeat the UNIX prompt. See Running Scheme for the different ways you can run scheme.
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:
(load "filename.scm")but this is tedious, so I don't recommend it.
You should do M-x load-library, type xscheme at the prompt, and then you can do a M-x run-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.
Edwin | 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.
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.
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.