IndexDeliverablesResourcesCourse PoliciesQuick LinksGot a question?Got a question or comment? Contact us at (515) 294-6168 or hridesh@cs.iastate.edu. |
Running Scheme This page is organized as follows: Running Scheme on Departmental Unix Machines The departmental Unix machines are the recommended platforms for course work. This section is organized as follows: We recommend using the DrScheme development environment in 342. There are other Scheme systems such as Chez Scheme, which you can also use if you wish, but DrScheme should be enough for the course. Starting DrSchemeThe DrScheme version 4.1.3 system can be used either on the department Linux machines, or you can download it to your home machine. There are versions for both Macs and PCs running Windows, as well as Solaris. If you download it for your home machine, see the Getting Other Stuff for your Home Machine section below for details. On the department Linux machines, the interpreter is found in /opt/plt/bin, so you must have the appropriate directory in your shell PATH for the interpreters to work. (But this is the default on the department servers, so you shouldn't have to do anything special to set this up.) On Unix, you can start the DrScheme system by using the following command at the Unix Shell's prompt: $ drscheme
Note: In code examples, green text is program output, yellow bold text is user input, and cyan text is sample code. and then hit the "return" (or enter) key. Be sure your input is in lower case (not CAPITALIZED). You should see a window pop up to load the system. If you see the error message "DISPLAY environment variable not set and no -display argument", this occurs because you are using ssh to access a department machine and you have not forwarded the X windows connection to the machine you are connecting from. The simplest fix for this is to run DrScheme directly on the machine you are on, instead of remotely on another machine via ssh. If you have a home computer, you can install the DrScheme system on that machine. If you don't have your own machine, come in to the department where DrScheme is installed on the machines and use it locally. Or you can forward the X windows connection, for example by using ssh -X to connect. Working with DrSchemeSelecting the Programming Language DialectOnce you have started DrScheme, a very important dialog comes up about selecting a (programming) language to work with. Most of these are simply dialects of Scheme. We suggest selecting the "Essentials of Programming Languages (3rd ed.)" language. To select the "Essentials of Programming Languages (3rd ed.)" language, open the "Language" menu, and then select "Choose Language..." and from the resulting popup, select the language named "Essentials of Programming Languages (3rd ed.)". This is under the group "Teaching Languages". Then press the "OK" button. Now, push the "Run" button to restart the interpreter. You should see that the language selected is now "Essentials of Programming Languages (3rd ed.)". Interacting with DrSchemeYou can type expressions into the bottom frame of the window that appears next, at the > prompt. The top window is where you can type definitions. These can be run and saved in files. See the help menu, especially the "Help Desk" menu item, for more information. It's worth taking the "Tour" that appears under the heading "Software" to see what's in the system. Making a Transcript in DrSchemeThere are three ways to print a record of your session with the DrScheme interpreter. First you can select "Print Interactions..." from the File menu. Or you can select "Save Other" from the File menu, and then choose "Save Interactions as Text"; after doing this, print the text file as you would normally. Or, if you wish, you can copy and paste the text you want to print into a text file, and print that in whatever way you normally do that. Note that DrScheme does not support Scheme's "transcript-on" facility. Loading FilesIn DrScheme, the easiest way to load a file is simply to open it, using the File menu, and then to press the "Run" button. Pressing the "Run" button loads the current text in the definitions part of the same DrScheme window (or tab). To load text in other windows (or tabs), be sure these files are saved first, then use load as described below. It is often convenient to put your code for Scheme programs in files, and have Scheme read those files. A standard way to have Scheme read a file is to use the load procedure. The advantage of this is that load can be called from a program; for example, you can have one file that loads several others. Another advantage is that you can use load after you have already started Scheme. An example of using load after starting Scheme is as follows: > (load "foo.scm")
If your files have errors you will see an error message; for example, > (load "foo.scm")
is an error message that means that foo.scm is missing one or more right parentheses (a common mistake). If the file is not found, it is possible that Scheme thinks it is in a different directory than you think it is in. To check the current directory, use (current-directory). To change the current directory to "c:\cs342\homework", use (current-directory "c:\\cs342\\homework"). If the file contains a module, then instead of using load, you should use require, as in the following example. > (require (lib "lambda-1-exp.scm" "lib342"))
Editing Scheme FilesThe easiest way to edit Scheme files is to use DrScheme itself. Simply open the file and edit in the window that appears. You can also edit Scheme files externally to DrScheme using any text editor, and load the file when needed. The main advantage of using DrScheme is that it provides language specific assistance such as syntax highlighting and matching of parenthesis. Running Scheme on Your Home Machine Download the DrScheme version 4.1.3, which is used for this course. It is available on many platforms, including Windows, Macintosh, Solaris, and several flavors of Unix. |