Higher-Order Programming » Lab Sessions

How to install DrRacket

Assistant: Bjarno Oeyen (bjarno.oeyen@vub.be)

During the Lab Session, we will make use of DrRacket as our IDE for writing Scheme programs. DrRacket is available on the lab computers on both Windows, Mac and Linux. Please read these instructions carefully on how to install and configure DrRacket for this course.

Installation

The lab machines already have DrRacket installed. If you are planning to use the lab machines you can skip this step but do not forget to create a personal account so you can save your files!

You can download DrRacket from https://download.racket-lang.org/. Install the latest version on your machine (instructions differ across different operating systems).

Configuring DrRacket

When you open DrRacket for the first time, no language will be selected. In this course, we will be using R5RS. There are multiple ways on how to write R5RS code in DrRacket but for ease of use, we will configure DrRacket such that R5RS is the default language.

  1. In the bottom-left corner, click on "Choose language" and click once again on "Choose language"
  2. Expand the window using "Show Details" and click on "Other Languages"
  3. Select under "Legacy Languages" the language "R5RS"
  4. On the right-hand side uncheck the box next to "Disallow redefinition of initial bindings"
  5. Click "OK"

Verify whether "Choose language" is changed to "R5RS custom".

Hello World

To verify that DrRacket is configured correctly copy-and-paste the following program in the editor (definitions window), and press the run key at the top of the screen. Make sure there isn't any other text in the definitions window.





After running the program the Read-Eval-Print-Loop (REPL) is shown on the bottom of the screen. It will first execute the program written in the editor, and will then resume by showing a prompt which can be used to evaluate Scheme expressions. If you are building a larger program, write your code in the definitions window as pressing run will clear the REPL.

Use R5RS in the terminal (optional)

If you are no fan of using the DrRacket IDE, then it is also possible to make use of the terminal. Follow these instructions after DrRacket has been installed.

  1. Be sure that Racket is available on your path.
    • For Windows: Add the bin directory of your Racket installation (usually in C:\Program Files (x86)\Racket v7.1\bin) to your path. Read How to Edit Your System PATH for Easy Command Line Access in Windows for more information (note that this guide is about adding the Android Developer tools to the PATH, so be sure to enter the correct racket path!)
    • For Linux: If you installed Racket via your package manager, it should already be available on the Path. If you used the official installer, follow its instructions. Make sure to install it globally if you want to make it available to every user on your system.
    • For Mac: Execute the following command in a terminal window: sudo sh -c 'echo "/Applications/Racket v7.1/bin" >> /etc/paths.d/racket' (change the path and version number if necessary)
  2. Restart your terminal (exit and reopen)
  3. Type in plt-r5rs --no-prim and press ENTER. You have installed Racket correctly if the Read-Eval-Print Loop (REPL) is started.

There are two ways to load a file in plt-r5rs...

  1. Run the file (without REPL) by running plt-r5rs --no-prim <filename>
  2. Load the file (inside a REPL) by running entering (load "<filename>") inside the Read-Eval-Print Loop