Using DrScheme with 6.034
DrScheme is an open-source integrated development environment (IDE) for Scheme maintained by the PLT group. Although DrScheme is available also on Linux, there are subtle differences in file placement and path issues and MIT/GNU Scheme is available on these platforms. We are therefore not currently supporting PLT DrScheme for Linux.Warnings
First, our support for DrScheme is highly experimental. We have little experience with it, though 6.001 has used it successfully. As a result, we recommend that, if at all possible, you use MIT Scheme instead, as described on the main Resources page. You can run MIT Scheme from any Linux-Athena or machine, such as those available in any of the clusters around campus, or a Windows machine. Please e-mail the 6.034 staff if you encounter problems using DrScheme so we can work out the bugs.
DrScheme's variants of scheme are not the same as MITScheme dialect, which what we officially support in this course. Due to the unavailability of a MIT/GNU scheme interpreter on non-Intel architectures, however, we are providing experimental DrScheme support.
On another note, we recommend AGAINST running scheme remotely via ssh/X-forwarding on public dialups, as public dialups are not for use for compute-intensive processses. Your scheme projects will likely often be very compute-intensive.
Setting up DrScheme
Step 1: Download and install DrScheme
The first thing you need to do is download the binary build of DrScheme and run the installer. It should be similar to installing any other familiar software applications.
Download: DrScheme (Current version 372)
Step 2: Add 6.034 extension libraries to DrScheme
The Scheme dialects used by DrScheme (r5rs/mzscheme) lack many of the familiar primitives in MIT Scheme. In order to make our example code run on DrScheme, we have provided a set of compatibility libraries that make some of the commonly-used MITScheme definitions available in DrScheme. We have provided these in a tarball linked below.
To download this file, right-click on the following link and select Download linked file or Save Target As.. to make sure your browser does not automatically unzip/untar the file. Have your browser save the file to your Desktop.
Linux
Download: drscheme_6034lib.tar.gz (Current version 2.15)
After you have downloaded the file, install DrScheme as a single unit into a folder where you have write access. Installing it to /usr/plt (the default) or /usr/local/plt will cause permission errors later. Assuming you have downloaded the DrScheme version 372 installer to your home directory, you can perform the installation with the following commands:
In a terminal, type:
chmod +x plt-372-bin-i386-linux.sh ./plt-372-bin-i386-linux.sh
This will start the DrScheme installer. Note that the name of the installation file will vary according to your linux distribution. On Ubuntu it would be plt-372-bin-i386-linux-ubuntu.sh, and on Fedora it would be plt-372-bin-x86_64-linux-f7.sh or plt-372-bin-x86_64-linux-fc6.sh. In the instructions above, please use the name of the installer file you downloaded instead of plt-372-bin-i386-linux.sh.
Once the installer starts, it will ask a few questions.
- The first would be "Do you want a Unix-style distribution?". Say no (the default option).
- The second would be "Where do you want to install the "plt" directory tree?". Select option 3 ($HOME/plt) to install into your home folder.
- The last question would be if you want to install system links into bin, lib, etc. Here you can choose to do what you want. The default to skip creating links will work just fine.
After installation, assuming you have downloaded drscheme_6034lib.tar.gz to your home directory, run the following commands:
In a terminal, type:
cd plt tar -xzvf ~/drscheme_6034lib_2.15.tar.gzThis completes the installation. You can now delete the DrScheme installation file and drscheme_6034lib_2.15.tar.gz from your home directory.
Windows
Download: drscheme_6034lib.zip (Current version 2.15)
After you have downloaded this file, unzip\untar it into the base PLT Scheme v372 directory. This directory is usually located in C:\Program Files\PLT, but may be in a different place if you chose a different target location during the installation.
Mac OS X
Download: drscheme_6034lib.tar.gz (Current version 2.15)
After you have downloaded this file, untar it into your PLT Scheme v372 directory (usually located in /Applications/PLT Scheme v372) as follows :
In a Terminal, type:
emax$ cd /Applications/PLT\ Scheme\ v372/ emax$ sudo tar xzvf ~/Desktop/drscheme_6034lib_2.15.tar.gzWarning: Note that latter command uses sudo because it needs root access to write to the /Applications/PLT\ Scheme\ v372/ directory. Please be careful to write the command carefully as shown above. If you have updated to OS X 10.5 (Leopard), however, the default place where files are downloaded is
~/Downloads
, not ~/Desktop
, so you would need to adjust these instructions. Also, depending on your web browser configuration, the process of downloading this file may have automatically expanded it to a tar file. In that case, your second command should be just
emax$ sudo tar xvf ~/Desktop/drscheme_6034lib_2.15.tar
After this is done you can delete the original drscheme_6034lib.* file that you downloaded.
Step 3: Choosing a Language
The final thing you need to do is run DrScheme and load the provided 6.034 libraries. Launch DrScheme by double-clicking the DrScheme application icon in PLT Scheme v372 in Finder. Then, open a new IDE window by going to File->New (or using command-N). Change the Scheme language of this window to Pretty Big, by going to Language menu, selecting Choose Language and selecting "Pretty Big" under the PLT group.
When you have "Pretty Big" selected, press Show Details at the bottom of the dialog box. This will reveal an expanded panel for language options; look for Input Syntax and make sure "Case sensitive" is unselected.
Then hit Ok and press the Run button in your open windows to commit your changes.
Step 4: Load compatibility libraries
Prior to running any 6.034-specific code, you should load the 6.034 compatibility libraries we provided. To do so, type at the Read-Eval Print Loop :> (require (lib "init.ss" "6.034"))
Note than every time you restart your DrScheme interpreter (such as by hitting Run, or opening a new interpreter window, or quitting/restarting DrScheme) you will have to re-execute the above require command to load the 6.034 extension libraries. So, you may find it convenient to add the (require (lib "init.ss" .. to the top of your load/run files.
Step 5: Run your code!
Then you're all set! You can check that everything went OK by verifying the existence of a sort method in your environment, such as:
> sort #<procedure:sort>
Finding Documentation
Most of the documentation for DrScheme is available on the PLT Scheme web site, including the MzScheme Language Manual.Questions/comments?
As usual, please contact 6034sp-staff@csail.mit.edu if you have any problems or suggestions!
Examples of Miscellanous Useful Scheme Stuff
Functions
(current-directory "/mit/6.034/ps1")Changes the working directory.
(current-directory)
Print the working directory.
(load "match.scm")
Loads and evaluates contents of a file (here, match.scm).
(require (lib "trace.ss"))
(trace func)
Shows the input arguments and output value when the function is called. Redefining the function, such as by loading a file that defines it, undoes the tracing.(untrace) will also remove tracing.
You may find a more comfortable general-purpose display function to be:
(define disp (lambda args (letrec ((disp-in (lambda (arg) (if (null? arg) 'Done (begin (display (car arg)) (disp-in (cdr arg))))))) (disp-in args))))
which will allow you to do things such as:
(define foo 42) (disp "The answer is " foo " nodes.")
and get:
The answer is 42 nodes.