Transcripts and File Loads

One of a series of tutorials about Scheme in general
and the Wraith Scheme interpreter in particular.

Copyright © 2011 Jay Reynolds Freeman, all rights reserved.
Personal Web Site:

In the tutorial, "Editing a File", I have already described how to use Wraith Scheme's "Reload Last File" and "Automatically Reload Last File After You Save Changes" features to develop Scheme source code interactively, using your favorite editor, and how to load a source code file into Wraith Scheme automatically, whenever you save out an updated version of the file. There are many other ways to load files into Wraith Scheme, and to save text or other data created there, both by using standard procedures of R5 Scheme and by using enhancements that Wraith Scheme provides. This tutorial provides an overview of a few of those other ways that may be particularly handy in day-to-day use of Wraith Scheme; it does not discuss all of the standard procedures for reading and writing files from Scheme.

First, in case you can't remember anything else or don't want to bother, you can always use the standard Macintosh cut-and-paste and drag-and-drop mechanisms to move text to and from Wraith Scheme. Text dragged or pasted into the Wraith Scheme Input Panel will be processed as if you had typed it. You may have to type a final "return" character if your pasted or dropped selection does not already end in one. The Wraith Scheme Main Display Panel -- where output from Wraith Scheme appears -- does not allow you to edit its content, but you may select text there by marking and dragging in the standard Macintosh manner, then copy or drag the selection wherever you like for whatever purpose you wish.

You can obtain a complete record of all of your text interactions with Wraith Scheme -- everything you type into the input panel, properly interleaved with all of Wraith Scheme's output -- by using the standard R5 procedures for transcript files. For example, assuming for the moment that your Macintosh hard disc is named "Macintosh HD" and that your user name is "Tiger"

will open a text file named "TodaysTranscript" in the Documents folder of your home directory, and will start copying into it everything you type to Wraith Scheme and everything that Wraith Scheme types back. If there already is a file of that name in that location, it will be overwritten: The old file will be lost. The transcript file will remain open and will continue logging text until either Wraith Scheme stops running or you evaluate

Any given Wraith Scheme process can have only one transcript file open at a time; running "transcript-on" twice without an intervening "(transcript-off)" automatically closes the first transcript file as it opens the second one. Notwithstanding, and getting way ahead of myself for a moment, if you are using Wraith Scheme's parallel processing capabilities and have two or more cooperating Wraith Scheme processes open at the same time, each one may have its own separate transcript file open.

The implementation of "transcript-on" in Wraith Scheme has an enhancement: If you evaluate

with no file name provided, Wraith Scheme will use the Wraith Scheme Dialog Panel to prompt you for the file to use.

The usual way to get Wraith Scheme to load source code from a file is with R5 Scheme's standard "load" command. Several of Wraith Scheme's enhancements and user-interface features make use of it, and we will get to them in a moment, but let's start out by considering the basic procedure itself. As you might expect

loads file "/Macintosh HD/Tiger/Documents/MySchemeSource". Yet I should take care to describe carefully just what "loading a file" means. What happens is intended to be what would happen if you had actually typed the text content of the file into the Wraith Scheme interpreter, and Wraith Scheme had evaluated it, except that the actual text itself does not appear in the Wraith Scheme Main Display Panel. All that appears in the main display panel upon loading a file are the results returned by the evaluations. For example, if "MySchemeSource" contains

then what appears in the Wraith Scheme Main Display Panel is just

since what a "define" returns is the symbol that has just been defined. Of course, the evaluation of that definition will have installed the variable "my-favorite-number" in Scheme main memory, with value 42, so that if you subsequently type

and press "return", then Wraith Scheme will type back at you

It is worth noting that the content of the file loaded is evaluated at top level in the Wraith Scheme interpreter: You might possibly think that if you executed a "load" procedure in the interior of a running Scheme program, the content of the loaded file would somehow be made available only to the interior of that program, or something like that. That doesn't happen: The content is evaluated at top level, no matter were the "load" happens. Any variable definitions and the like from the loaded file will be available at top level, for use by any procedure.

Wraith Scheme's "load" procedure has the same enhanced behavior as "transcript-on". When "load" is invoked without an argument, Wraith Scheme uses the dialog panel to prompt for the name of the file to load.

File loads may be nested. That is, a file being loaded may itself contain "load" commands, which will cause the loading of the source files to which they refer, after which the original "load" will pick up where it left off.

Several menu items in Wraith Scheme's Interpreter Menu invoke the "load" command.

Interpreter Menu

The "Load File ..." menu item (command-L) opens a standard Macintosh file browsing panel for selecting the file to load.

The "Load Recent ..." menu item opens a whole submenu of names of files that have been loaded into Wraith Scheme recently. There may be up to forty files in the submenu, and the file names are remembered when Wraith Scheme is not running. Moving the cursor over an item on the submenu will bring up a standard Macintosh tooltip containing the complete path to the file.

In the tutorial, "Editing a File", I have already mentioned the menu item "Reload Last File" (command-option-L), which has a pushbutton equivalent in the Basic Buttons Drawer: This menu item is available only when at least one file has been loaded into Wraith Scheme since the program was started; it reloads the most recent file loaded. Checking the "Automatically Reload Last File After You Save Changes" menu item, or depressing the corresponding button in the Basic Buttons Drawer (it stays down when you push it), will cause Wraith Scheme automatically to reload the last file loaded whenever that file is changed, such as when you save a new version of it from an editor.

-- Jay Reynolds Freeman (

Wraith Face