Scheme Setup Instructions

In 6.188, we will be using a program called DrScheme as our scheme interpreter. DrScheme is a free implementation of scheme written by the Rice University Programming Language Team (PLT). We are using DrScheme because it has many advanced syntax analysis and debugging features that are not available currently in MIT Scheme.

You can either run DrScheme from Athena or you can install/run DrScheme on your own PC. It has versions that support Windows, Linux, and MacOS.

Download/Installation

For Athena users, DrScheme is already installed. You can run DrScheme by entering the following commands from any Athena-Linux workstation.

athena% add drscheme
athena% drscheme &

To run it from your own PC, download and install the version appropriate to your operating system by going to:

The DRScheme download site

Find, download, and run the installer specific to your system. During installation, accept all the default settings.

Once you've installed the program, run DrScheme.

Selecting a Language

DrScheme requires that you select a language before you can do anything. So in the DrScheme window, goto the menu: Language > Choose Language... and select: PLT > Pretty Big (...). Once the language is selected, press Run.

After you have configured everything, check to make sure that you have a window like the following:

Your First Program

The DrScheme GUI is divided into two panels: a definitions window (top) and an interactions window (bottom). The definitions window is where you enter and edit your program. The interactive windows contains a scheme interpreter running in a read-eval-print loop; this is where you test your program.

Enter the following code into the DrScheme definitions window:

(define hello-world (lambda () (display "hello world!")))

(define square (lambda (x) (* x x)))

(define sum-squares
  (lambda (x y) (+ (square x) (square y))))

(define pythagoras
  (lambda (y x) (sqrt (sum-squares y x))))

This example contains: a simple "hello world" procedure, and 3 procedures that were covered in the first chapter of online tutorial. Next, press Run. Run will load (or interpret) the program you've just entered. It will also reset the interactive window.

Next, you can test your code by calling the procedures you've just loaded.

In the interactive window, enter the following commands:
(The text after the > is what you type, and the subsequent line is what DrScheme outputs)

> (hello-world)
Hello world!
> (square 5)
25
> (pythagoras 3 4)
5
> (sum-squares 5 6)
61
> 

Check to make sure you get the same outputs.

Saving your program

Now that you have created your first scheme program, you'd likely want to save it and come back later to work on it some more. Click on the save button (or typing ctrl-s) to save your work to a file. You should save it as a Scheme (.scm) file. Give it a readable name such as "my-first-program.scm". For exercises that you do in the course, you should name your files according to the problem set you are working on, e.g. "ps-1.1a.scm".

Besure to remember to also put comments at the top of code files you create. Your comments should contain at least the following pieces of information:

;; Name:  <your name or names if its a group project>
;; Class: <class that the assignment is for>
;; Assignment: <assignment name>
;; Date:  <the date you created this file>
;;
;; <A brief description of the contents of this file>

Lines preceded with ";" are comments in Scheme, and are safely ignored by the Scheme language interpreter.

Loading your program

Close and reopen the DrScheme program. Load your saved program ("my-first-program.scm") by going to "File > Load" (or typing ctrl-o). After loading, press Run to start the DrScheme interpreter window. Rerun the commands you entered above to make sure you get the same output.

Resources

We've just covered the basic functionality of DrScheme that you'll need to work on the problem sets in 6.188. While working through the on-line tutor, you should type and debug your problems in DrScheme. When you are done, you can copy and paste your solution to the tutor page.

If you are curious about the many features of DrScheme, there is a comprehensive set of documenation for the DrScheme program (and for scheme in general) available from:

DrScheme documentation.

If you are stuck with setup or installation issues, you should email the 6.188 staff so we can help you get started as soon as possible.


Maintained by: Yuan Shen - 2/25/2006