Wraith Scheme Help File

Main Window

Wraith Scheme Help File

Copyright © 1988, 1989, 1990, 1991, 2006, 2007, 2008 Jay Reynolds Freeman, all rights reserved.
Personal Web Site: http://web.mac.com/Jay_Reynolds_Freeman
EMail: Jay_Reynolds_Freeman@mac.com.

NOTICE:

If you can't find what you are looking for in the table of contents, use the "Find" command -- in either the Apple Help Viewer or your HTML browser, whichever you are using to view this file -- to locate words and phrases.

Table of Contents:

Introduction:

Wraith Face

Welcome to the help file for Wraith Scheme, an implementation of the Scheme programming language for the Apple Macintosh™. Wraith Scheme was written by me, Jay Reynolds Freeman. By all means Email me about it if you wish.

I believe Wraith Scheme is a complete implementation of the "R5" dialect of Scheme (major Revision 5 of Scheme). There is one caveat to the word "complete": The R5 report (citation in next paragraph) describes a number of optional Scheme features, using language like "some implementations support ...", or something similar. Wraith Scheme does not support all of these optional features. A list of optional features that are missing is here.

This document is not a complete Scheme language description or programming manual. For a complete and authoritative manual, I strongly recommend that you obtain and peruse a copy of the 1998 Revised5 report on the Algorithmic Language Scheme, edited by Richard Kelsey, William Clinger and Jonathan Rees. That report is available on several Internet sites, such as http://www.schemers.org.

You might also consider reading some of the Scheme References and Lisp References listed later herein.

Wraith Scheme is shareware: You are welcome to use Wraith Scheme for free, forever, and to pass out free copies of it to anybody else. If you should at some time wish to make a shareware donation for Wraith Scheme, use my PayPal&trade account or send a check by regular mail to

Jay Reynolds Freeman
Post Office Box 60628
Palo Alto, CA, 94306-0628
U. S. A.

PayPal will need my EMail address:

Jay_Reynolds_Freeman@mac.com

How much to donate is your choice.

Wraith Scheme was named after my late, lamented, scruffy gray cat, "Wraith". If you don't think that makes sense, remember that it runs on a computer named after a raincoat. Wraith Scheme is a direct descendent of Pixie Scheme (another cat), which I wrote in the late 1980s for early versions of the Apple Macintosh™.

Getting Started:

By all means, read through this material and the next section or two following it, but you might also want to look at the section, Common Problems and Solutions.

System Requirements:

Wraith Scheme is a stand-alone application for the Apple Macintosh&trade. It is universal binary, and thus should run on any Macintosh with either an Intel microprocessor such as the Core Duo&trade, or one of the older PowerPC&trade microprocessors. Wraith Scheme requires the Apple OS X operating system, version 10.4 or later. Its memory and disc requirements are minimal: The program occupies less than 4 Megabytes of space on disk, requires about 30 MBytes of memory to run with its default "preferences" settings, and can run usefully while using less than 10 Megabytes of memory.

Installation:

An installation of Wraith Scheme comprises just the "Wraith Scheme" application itself -- there are no extra files. The Wraith Scheme application contains some extra items embedded within it, such as HTML help files (including this one), a "README" file, and some examples of Scheme source code, so that all you really need is the application. (By the way, in case you obtained this help file as a separate download, the "Wraith Scheme Help" menu item, in Wraith Scheme's "Help" menu, will call up this same file from within the program -- you don't need a separate copy.)

"Installation" is simply the act of putting the application wherever you like. Possibly it should end up in your "Applications" folder, but that choice is up to you.

Wraith Scheme is what might be called "classic shareware": It depends solely on your generosity for support, with no strings attached. In particular, there is nothing to register, there are no activation codes required, and there are no enhanced versions available for a price. The shareware product, "Wraith Scheme", is all there is. Furthermore, Wraith Scheme will not emit annoying reminders to send me a shareware donation.

You are welcome to make as many backup copies of Wraith Scheme as you wish, and to give free copies of it to anyone.

Security:

Most people consider it ill-advised to run an unknown application -- like Wraith Scheme -- without special precautions, because it might contain code to do something malicious. If I had deliberately written a malicious program, I certainly wouldn't tell you, at least, not until it was way too late. What's more, if you are a suspicious type -- and in today's Internet and computing environment, you should be! -- there is nothing I can do or say to convince you that I have not put some ill-intended code into Wraith Scheme. Actually, I suppose it might help if I told you where I live, but I myself am a suspicious type, so I am not going to do that.

Besides, my house is a mess.

It might be useful to remember that Apple's OS X operating system is based on Unix: If you have moderate Unix experience, you might know that Unix is pretty good about keeping one user from messing with other users' data. Thus you might create a special, "dummy", user account, just for testing Wraith Scheme, with access to nothing other than Wraith Scheme and any files of Scheme code you may be using. If you know how to do that, good. If not, perhaps you should seek advice from a Unix-knowledgeable and trustworthy friend. (You shouldn't rely on me to provide the details; for all you know I am a computer criminal who might deliberately tell you something that didn't work and thereby set you up for disaster.)

Furthermore, one thing I worry about -- something every software developer worries about -- is that some third party will modify my code to be malicious, or create a malicious program with the same name and appearance as mine, and produce nefarious results thereby. I have no way to avoid this problem; nobody does.

Starting Wraith Scheme:

Just click on the Wraith Scheme icon, and away you go. The program will open up a window that looks like this:

Main Window

The Wraith Scheme Main Window, at reduced size.

In case you can't read the image on your browser, the messages shown at startup will be something like:

The "Top-level loop..." message means that Wraith Scheme has completed initialization and started doing what a Scheme interpreter does -- running an endless loop of reading Scheme code that you type in, processing (more precisely, "evaluating") what it read, and printing out the results.

Wraith Scheme Startup Actions:

On startup, Wraith Scheme

Changing the Startup Defaults:

All of Wraith Scheme's preferences take effect at startup, so as you learn later herein what those preferences are, remember that you can change Wraith Scheme's startup behavior by changing them.

In particular, you might write your own file to be loaded on initialization, and set the preferences to load it. Such a file might contain text like:

(By the way, Scheme source files do not have to end in ".s". That is merely a personal convention of my own.)

Alternatively, the file could load a Wraith Scheme world that you had previously saved.

Perhaps you would not like to have any file loaded at all at startup -- maybe you are sick of seeing the demonstration program run. In that case, delete the text in the "Load This Source File After Startup" field in the preferences window, so that it looks like this:

Preferences Window, blank file field

Changing How it Looks:

If you don't like the way the Wraith Scheme main window looks, there are plenty of ways to change its appearance. There is all the usual Macintosh stuff for customizing the user interface, and in particular:

Interacting with Wraith Scheme:

While you are reading this section, remember that there is also a section called Common Problems and Solutions.

Wraith Scheme provides one main window, a few buttons, and a generous handful of menu items. The main part of the Wraith Scheme Window is where you do almost everything with the Wraith Scheme program -- things like entering Scheme source code, running it, and looking at the results. The buttons, menu items, and a few accessory panels -- Apple calls them "drawers" -- that slide out from the main window allow you to do things to the Wraith Scheme program -- things like setting options and taking control of Scheme programs that are misbehaving. They also allow you to keep track of what Wraith Scheme is doing.

There is one other way of interacting with Wraith Scheme that may be particularly useful: Wraith Scheme makes considerable use of "tooltips" -- the brief text descriptions that pop up when the cursor is positioned over particular areas of the screen. You can learn something about almost any visible feature of Wraith Scheme by moving the cursor over it and waiting for a tooltip to appear.

Note that Wraith Scheme requires ASCII characters for everything it does. (ASCII characters are pretty much the letters of the English alphabet and the standard punctuation marks -- what you could get from the keyboard of an old-fashioned typewriter.) That requirement includes the names of files and folders that Wraith Scheme might have to deal with, and in the case of files, it means that Wraith Scheme will complain if the folder containing the file has a name containing non-ASCII characters, or if the folder containing that folder does, and so on.

Let's discuss the window, buttons, and menu items in more detail:

The Wraith Scheme Window:

Main Window

The Wraith Scheme Main Window, at reduced size.

Mostly, you type Wraith Scheme commands into the Wraith Scheme window, and look there to see what happened.

The Input Panel:

Input Panel

The left end of the Input Panel, full size.

You type into the panel at the bottom of the window that is one line tall and almost as wide as the whole window. That panel is surrounded by black lines. Input to Wraith Scheme is line-at-a-time. Wraith Scheme will process an entire line when you press the "return" key. If you are typing a Scheme expression that takes several lines and notice a mistake after you have already pressed the "return" key for that line, you can press the "Discard Input" button, or use the corresponding menu item in the Interpreter Menu, to start over.

You do not need to have the cursor at the right end of the line when you press the "return" key. Wraith Scheme will get to process the entire line when you press "return", no matter where the cursor is positioned in the line.

The one-line panel where you type provides standard Apple text-editing capability, including cut-and-paste and drag-and-drop. It is in fact a scrolling window, though there is no scroll bar to tell you so, and only one line of its text will be visible at any given time. You may use the up-arrow and down-arrow keys to scroll back and forth among lines of text that you have previously typed. For convenience, there are buttons labeled "Previous Command" and "Subsequent Command" that also scroll this window.

If you type a single line -- with no "return" -- that is longer than the Input Panel is wide, the line will "wrap", and you will only see the last part of it in the Input Panel. Don't worry. It's all there, and you can use the keys to move back and forth in a line to get to the first part of it, if necessary. Wraith Scheme will finally "see" the entire line, and start to process it, when you get around to pressing the "return" key.

When you have scrolled to a line that you previously typed, and have the cursor on that line, you may press "return" to send that line of text to Wraith Scheme again. You can re-enter a Scheme expression that spanned more than one line, one line at a time: Use the scroll commands to retrieve the first line of the expression, press "return", use the arrow keys to retrieve the second line of the expression, press "return", and so on.

The Macintosh's "cut-and-paste" and "drag-and-drop" mechanisms are very useful for entering Scheme expressions.

Although you can only edit one line of text in the Wraith Scheme window, Scheme commands may span more than one line. For example if you type (with a final "return")

the effect is the same as if you had typed (again with a final return)

That is, Wraith Scheme prints out

The Main Display Panel:

MainDisplayPanel

The Main Display Panel, at reduced size.

The Main Display Panel is the big panel that covers most of the Wraith Scheme window. It shows copies of the text that you have submitted to Wraith Scheme, interspersed with whatever Wraith Scheme has printed out in response. You cannot edit that text, but you can select it for cut-and-paste or drag-and-drop to some other location, such as the Wraith Scheme Input Panel. The Main Display Panel scrolls too, using the scroll bar at the right edge of the main window.

Both the input window and the main display window can store essentially unlimited amounts of scrolled-back text, but if for some reason you want to reduce the amount of scroll-back, there is a "Trim Scrollback" menu item in the Interpreter Menu, that does so. Every time you use it, it trims off the oldest half of scrolled text in each window, down to 20,000 characters. That is, this command will never reduce the amount of scrolled-back text in either window to less than 20,000 characters.

The Message Panel:

The Message Panel is the top line of the Wraith Scheme window. Wraith Scheme will occasionally print messages there, that tell something about what the Wraith Scheme program is doing. One message that you will probably see a lot is "Garbage collection completed." Any message printed will go away after about ten seconds.

Message and Dialog Panels

The Message and Dialog Panels, slightly reduced.

The Dialog Panel:

The dialog panel consists of the second and third lines from the top of the Wraith Scheme window, which are isolated from the rest of the window by a horizontal line beneath them. Wraith Scheme will start a dialog with you by printing a prompt message in the first line of the panel, and will then move the cursor to the start of the second line of the panel and wait for you to enter your reply -- one line only. Type the line, using the same line-editing commands as for the main window, and type a final "return" when you are done.

As a visual cue that a dialog is in progress, the prompt message will display in colored text, cycling through several colors, to draw your attention to the fact that Wraith Scheme is waiting for you to do something.

You don't actually need to type a response: You may use cut-and-paste or drag-and-drop to make your response, so long as it's just one line long.

To remind you of what has been going on, Wraith Scheme will leave the text of the last dialog visible in the dialog panel, with the prompt message in the normal color, until the next dialog begins.

In a typical dialog, Wraith Scheme might ask you the name of a file to load.

The Basic Buttons Drawer:

Basic Buttons Drawer

The Basic Buttons Drawer, full size.

The Basic Buttons Drawer slides out from the left side of the Wraith Scheme window. You make the drawer open and close with the "Show Basic Buttons" menu item in the Window Menu, or you can drag the left edge of the drawer with the mouse to slide it in and out. Its buttons do the following things:

The Basic Buttons drawer contains one more useful item, but it is not a button. Near the bottom edge of the drawer, close to the left end of the Input Panel, is a small text field that is normally invisible because it contains no text. When you are entering a Scheme expression that takes more than one line, this field will contain text to remind you of how many right parentheses you need to complete the expression, if any, or if you are in the process of typing a text string that spans more than one line, it will remind you that you need a quotation mark (") to complete the string. I put this feature in because many times I have sat bewildered in front of a Lisp or Scheme interpreter, wondering why the command I had just typed wasn't doing anything, without realizing that I had to type something else to finish it.

Thus if you type the following line into the input panel -- note the unbalanced parentheses -- followed by "return":

The little field at the bottom of the Basic Buttons drawer will remind you:

Here are some images that show this field in operation:

Expect Right Parenthsis

Expect Quotation Mark

Wraith Scheme will remind you when what you have typed has unbalanced parentheses or a missing quotation mark. (Images shown full size.)

The basic buttons drawer is set up so that if you close it part way, the edges of the buttons remain visible, and the little reminder field at the bottom also remains visible. Thus, once you have enough experience with Wraith Scheme to know which button is which without reading the label on it, you can save space on your display by closing the basic buttons drawer most of the way, and still use all of its features.

The Wraith Scheme Instrument Panel:

Instrument Panel

The Wraith Scheme Instrument Panel, slightly reduced.

The Wraith Scheme Instrument Panel is a drawer that slides out from the bottom of the Wraith Scheme window. You make the drawer open and close with the "Show Instrument Panel" menu item in the Window Menu, or you can drag the bottom of the drawer with the mouse to slide it in and out.

The instrument panel contains no buttons or other controls; all it does is display some information about what Wraith Scheme is up to and what it has been doing. Many of the items displayed are self-explanatory; the meanings of the others are described elsewhere herein. Don't forget to move the cursor over items to read the tooltips associated with them.

In particular, the instrument panel shows the names of the last world file loaded, and of the last file of Scheme source code loaded. To see the complete path for either of these items, move the cursor over the file name, and the full path will pop up as a tooltip.

Several of the items displayed in the instrument panel are "status lights", that go on and off when the item whose status they monitor changes. If you don't think these are useful, I at least hope you think they are cute. Every computer ought to have status lights, preferably ones that blink a lot ...

When Wraith Scheme is busy, the instrument panel display will lag behind what Wraith Scheme is doing, but it will catch up when it gets the chance.

The instrument panel is set up so that if you close it part way, the items at the bottom of the panel are covered up, and the items at the top of the panel remain visible. I have put what I believe are the most important items in the instrument panel at the top. Thus, if you want to save space on your display, you can close the instrument panel most of the way and still see the most useful information that it contains.

When the Basic Buttons Drawer and Instrument Panel are both partially closed, the Wraith Scheme Main Window might look like the image that follows. Note that there is still enough of the buttons visible to click on them:

Main Window Partial Drawers

The Wraith Scheme Main Window, with Basic Buttons Drawer and Instrument Panel partially closed, at reduced size.

When the Basic Buttons Drawer and Instrument Panel are both closed, the Wraith Scheme Main Window looks like this:

Main Window No Drawers

The Wraith Scheme Main Window, with Basic Buttons Drawer and Instrument Panel completely closed, at reduced size.



Menu Items:

MenuBar

Wraith Scheme's complete menu bar, full size.

The Wraith Scheme Menu:

Wraith Scheme Menu

The Wraith Scheme Menu, full size.

The items in the Wraith Scheme menu are pretty much Apple standards. Only three require special discussion for Wraith Scheme:

The Interpreter Menu:

The Interpreter Menu items have to do with your interactions with Wraith Scheme in the Wraith Scheme window.

Interpreter Menu

The Interpreter Menu, full size.

The Edit Menu:

Edit Menu

The Edit Menu, full size.

The Edit Menu contains only standard Apple items. There is no "undo" or "redo" for typing, because these items don't make much sense when typed input is promptly being processed by Wraith Scheme.

The Font Menu:

Font Menu

The Font Menu, full size.

The font menu allows you to increase ("Bigger") or decrease ("Smaller") the font size in the Wraith Scheme window, within limits. The smallest font available is 9 point, and the largest is 36 point. When you use these menu items, the size of all text in the Wraith Scheme window changes all at once -- they aren't "mark and click" style menu items.

The "Change Text Color..." menu item opens up a small window that allows you to change the text color Wraith Scheme uses. That small window contains a standard Macintosh "color well" that you may use to select a color. Once you have done so, use the "Preview" button to see how the color looks in the Wraith Scheme window. When you have a color you like, use the "Done" button to make the small window close. Alternatively, use the "Cancel" button to leave the background color the way it was when the small window first opened.

Change Text Color Window

The Change Text Color Window, full size.

When you use the "Change Text Color..." menu item to pick a new text color, and press the "Done" button, Wraith Scheme will ask if you want to make the new color a preference, so that it will automatically be used the next time Wraith Scheme starts up. If you reply "Yes", Wraith Scheme will put the new color into the "Preferences" window on your behalf.

The "Change Background Color..." menu item opens up a small window that allows you to change the background color of areas where Wraith Scheme displays text. That small window contains a standard Macintosh "color well" that you may use to select a color. Once you have done so, use the "Preview" button to see how the color looks in the Wraith Scheme window. When you have a color you like, use the "Done" button to make the small window close. Alternatively, use the "Cancel" button to leave the background color the way it was when the small window first opened.

Change Background Color Window

The Change Background Color Window, full size.

When you use the "Change Background Color..." menu item to pick a new background color, and press the "Done" button, Wraith Scheme will ask if you want to make the new color a preference, so that it will automatically be used the next time Wraith Scheme starts up. If you reply "Yes", Wraith Scheme will put the new color into the "Preferences" window on your behalf.

The Window Menu:

Window Menu

The Window Menu, full size.

Many of the contents of the Window Menu are standard Apple menu items. but four are not:

The Help Menu:

Help Menu

The Help Menu, full size.

The Help Menu provides access to some rather lengthy HTML files that tell how to use Wraith Scheme.

If for some reason you would like to access these files by some means other than using the menu items, there's a way. The files themselves are buried deep within the Wraith Scheme application. To find them:

Another View of Interacting with Wraith Scheme:

There is another way to think about how you may interact with Wraith Scheme:

There are five ways for Wraith Scheme to provide information to you:

There are four ways for you to provide information to Wraith Scheme:

Error Handling:

When Wraith Scheme encounters an error from which it can recover, its general strategy is to print an error message -- I hope a useful one -- in the Main Display Panel, then abort whatever Scheme processing is going on and return control to you at "top level" in the Wraith Scheme window. For example, suppose you tried to divide by zero. You might type (with a final "return")

whereupon Wraith Scheme would print

A similar error message, and a similar return to the "top level" of control of Wraith Scheme, would occur even if the attempt to divide by zero occurred deep in some elaborate Scheme procedure.

Wraith Scheme may also encounter errors from which no recovery is possible, in which case its general strategy is to open a special panel with an error message and then exit. If you should ever see a fatal error message whose cause is not obviously due to some system limitation (such as not having enough memory), I would like to hear about it: Send bug reports to Jay_Reynolds_Freeman@mac.com.

Controlling Wraith Scheme:

Differences from R5 Scheme:

Herein I describe how Wraith Scheme differs from "R5" Scheme by going through the Revised5 Report on the Algorithmic Language Scheme, section by section, and listing differences between Wraith Scheme and that standard. It is my intention that any essential or non-essential feature of Scheme, as described in the R5 report, is either provided as described, or mentioned here with an indication of how Wraith Scheme differs from the R5 report.

One major difference is that Wraith Scheme provides numerous enhancements and special features, in great part in the form of extra built-in procedures and constants whose identifiers generally begin with "e::" or "c::". I mention some of these features in passing in this section, keeping the descriptions brief for clarity of presentation. I have described them in more detail in a separate Enhancements section.

I have summarized the R5 features that Wraith Scheme lacks, in the Optional Features Omitted section. Each missing feature is also mentioned separately in the discussion of the appropriate section of the R5 report, below.

R5 Section 1:

R5 Section 2:

R5 Section 3:

R5 Section 4:

R5 Section 5:

R5 Section 6:

R5 Section 7:

Optional Features Omitted:

In the section-by-section discussions above, of how Wraith Scheme differs from the R5 standard, I have listed the optional R5 features that Wraith Scheme lacks. These features are "optional" in that the R5 report mentions them, perhaps with such language as "some implementations support ...". Here they are once again, all in one place, in summary:

Enhancements:

This section describes Wraith Scheme's non-standard features, procedures and syntax. Many are rather conventional: Most implementations of Scheme will have them in some form, but they are sufficiently dependent on the particular computer and operating system in use that the R5 report cannot specify them. Others deal with matters of controversy in the Scheme community. Possibly some version of them will be incorporated into the standard at a future date. Meanwhile, I have provided what seems best to me.

There are a moderate number of enhancements that are specific to the look and feel of the Apple Macintosh, or that allow you to access special features of the Macintosh itself. And finally, there are some enhancements that allow you to inspect or modify parts of Wraith Scheme at a rather low level. Some of these may be useful in debugging programs, or in satisfying your curiosity about what's going on. Others are there because I needed them for some purpose related to developing Wraith Scheme.

Some of these enhancements are identified by naming conventions. In particular, Wraith Scheme uses symbols which begin with the characters "e::" for enhancements that in my opinion will probably be of broad interest to users, and "c::" for more specialized enhancements that will probably be less generally useful.

By and large, enhancements whose names begin with "e::" will be reasonably well-documented and will have reasonable handling of errors. They should be no risker to use -- with "risk" in the sense of unexpected crashes and mysterious behaviors -- than standard Scheme procedures, special forms, and macros. Furthermore, these enhancements are more likely to continue to exist in the same form in future releases of Wraith Scheme, or at the very least, I will make a big to-do in documentation if there are changes.

Enhancements whose names begin with "c::" will be less-well documented, riskier, and more likely to change in future releases. Most of the "c::" enhancements are provided for my own use in developing Wraith Scheme, or are auxiliaries used by standard Scheme procedures or by "e::" enhancements. I have left them in the release and documented some of them.

You might remember the distinction this way:

e:: for enhancement, c:: for caution

A cynic might have said:

e:: for enhancement, c:: for catastrophe

Compiler:

Wraith Scheme contains a simple compiler: What it produces is not native code for the Macintosh microprocessor, but merely a somewhat more optimized form of Scheme, which the interpreter can evaluate more quickly.

    Technical Note: The compiled code is of a form that is sometimes called "threaded", with the word used in the sense of "threaded interpreted languages" -- like Forth -- rather than in the sense of "process threads".

Wraith Scheme has an internal "compile defines" flag that causes each "define" automatically to compile the quantity being defined, provided that "define" is used with the syntax

    (define (<name> <argument ...>) ... )
    

that is, with parentheses around the function name and argument list.

That flag is turned on and off by checking and unchecking the "compile defines" item of the interpreter menu, or by using the procedures described in the Enhancements section under State Flags. With the flag on,

    (define (inc x) (+ x 1))
    

will create a compiled procedure called "inc", that adds one to its argument.

The idea of compilation is to do as much of the work of a program as possible just once, at compile-time, instead of many times, every time the program is run. Thus the compiler ...

  • Expands macros,
  • Precalculates the positions within the environment of variables (including the arguments) referenced by compiled procedures,

  • Inserts the actual values of variables that are "permanent", within the bodies of compiled procedures.

Code that has had these things done runs much faster than code that has not.

Even if the "compile defines" menu item is not checked, the compiler will expand macros in procedures that are "define"d using the syntax

    (define (<name> <argument ...>) ... )
    

If the "compile defines" menu item is not checked, there is still a way to compile things, using the procedure "e::compile-form":

    (e::compile-form <form>)
    

in which <form> evaluates to what you want to compile. "<Form>" will typically be either a lambda expression or a symbol to which a lambda expression is bound. You will probably wish to bind the value returned by "e::compile-form" to a symbol, for subsequent use. For example, you might first enter

    (define inc (lambda ( x) (+ x 1)))
    

or

    (define (inc x) (+ x 1))
    

followed by

    (define inc (e::compile-form inc))
    

The result in either case would be a compiled procedure called "inc", that adds one to its argument.

The compiler attempts to do something sensible with every <form>, but compilation has no effect on <form>s which do not evaluate to lambda expressions: Thus for example

    (e::compile-form '(1 2 3)) ;; ==> (1 2 3).
    

If you define a lambda expression with "compile defines" flag off, then turn it on, you can compile the expression easily, as shown here:

With "compile defines" off:

    (define foo (lambda ...)).
    

Then, after turning "compile defines" on:

    (define foo (e::compile-form foo))
    

The compiler includes some other procedures of interest:

    (e::define-no-compile <symbol> <form>)
    (e::define-no-compile (<symbol> ... ) <form> ... )
    

"e::define-no-compile" acts as "define" does when the "compile defines" flag is unchecked: That is, even if "compile defines" is checked, and even if quantity being defined evaluates to a lambda expression, nevertheless "e::define-no-compile" will merely bind the evaluated quantity to the <symbol>, without compiling it. Use "e::define-no-compile" to make sure something never gets compiled.

"e::define-no-compile" recursively searches its second argument for macro "calls", and expands any that it finds, before binding the result to the <symbol>.

Compiling and Permanence:

Effective use of the compiler requires understanding how it uses the "permanence" mechanism. To make a symbol permanent is to make a promise to the compiler, that whatever value is associated with the symbol at compile-time will continue to be associated with it at run-time. Thus the compiler can substitute the value for the symbol once and for all in compiled code, and save the time required to look up the symbol time after time, at run-time. The down side of permanence is that if you ever decide to make a permanent symbol un-permanent, and change its value, you will have to recompile all the procedures that use it, that were compiled while it had the first permanent value. Otherwise, those procedures will continue to use the old value.

The typical symbols you will probably wish to make permanent are the names of procedures, and there is a special procedure to help a bunch of compiled, permanent procedures all know that they are all permanent. That function is "e::substitute-new-permanent-symbols"; you use it on a procedure that has already been compiled, to let that procedure know about symbols that it contains, that have been made permanent after it was compiled:

    (e::substitute-new-permanent-symbols <form>)
    

Note that you do not have to bind the result of "e::substitute-new-permanent-symbols" to anything; that procedure modifies its argument: It looks through the function body for symbols that have become permanent, and substitutes in their values.

Here is some boiler-plate for how to use the "permanence" mechanism effectively in compiled code. Suppose that the "compile defines" menu item is checked, and that you wish to compile three functions, "foo", "bar" and "baz", that call each other, or that call themselves recursively, or both. The idea is to define them all first, then make them all permanent, then apply "e::substitute-new-permanent-symbols" to all of them. You do all this with the "compile defines" flag set:

    (define my-function-names '(foo bar baz)
    
    (define (foo ...) ...)
    (define (bar ...) ...)
    (define (baz ...) ...)
    
    (map e::set-permanent! my-function-names)
    (map e::substitute-new-permanent-symbols my-function-names)
    

Debugger:

The debugging mechanism provided with Wraith Scheme is very incomplete, though there is a hook for making it better. Wraith Scheme's mechanism for handling recoverable errors -- the kind that eventually return control to top level --knows to look for a symbol called "e::debug". If that symbol is bound to a procedure, the error-handling message will call it with a single argument. Thus you may create a debugger merely by defining "e::debug", like this:

    (define e::debug (lambda (x) ...))
    
Wraith Scheme will then call "e::debug" as part of its error handling, after the error message has been printed, instead of returning control to the top-level environment.

The argument to "e::debug" will be a non-empty list of all the environments in the lexical scope of the place where the error happened. The last member of that list will be the top-level environment: It will be a vector, each of whose elements is a list of symbols. Every symbol bound in the top-level environment will appear in exactly one vector element. If the list that is passed to "e::debug" has more members, its first member will be a list of the symbols bound in the lexical scope most local to the error, its second will be a list of the symbols bound in the next lexical scope outward, and so on till the top level. Only the last member will be a vector; all the others will be lists.

You may have your "e::debug" do whatever you like with this information. You might display the symbols. It will be hard to obtain their values, because the environment list passed to "e::debug" as an argument is not the one Wraith Scheme searches automatically from within "e::debug", when looki