Common Lisp at Oregon State University


Obtaining a Common Lisp Implementation

You have several options for running Common Lisp programs at Oregon State University. I will test all assignments on Gnu Common Lisp, Liquid Common Lisp, and Harlequin's Windows Common Lisp.


Common Lisp Documentation


Running GNU Common Lisp

You can start GNU Common Lisp by typing gcl to the shell. When it starts up, it reads the file init.lsp in the current directory. You can place customizations there. I recommend that you begin by installing the following init.lsp file.

The easiest way to run GCL on Unix is inside an emacs window. I strongly recommend that you learn to use emacs if you haven't already. To run GCL inside emacs, you need to add a few lines to your .emacs file to install the ILISP package. You can download them here, and insert them into your .emacs file.

With these changes installed, you can then restart emacs and type ESC x gcl RETURN to create a second window and start up GCL. You must issue this command from an emacs buffer that is attached to your home directory (for example, if you run emacs starting in your home directory, then the *scratch* buffer will work fine). Each complete expression that you type in this window will be sent to GCL when you hit Return. In addition, emacs will interact with GCL "invisibly" to implement various nice features, as described below.


Emacs commands for lisp

Emacs provides the following commands for editing lisp files, regardless of whether you are using the ILISP package mentioned above.

If you have installed the ILISP package, then there are several additional commands available:

There are many other wonderful commands. You can find out about them by reading the ILISP documentation (a postscript file). You can also type CONTROL-H m (help mode) to get concise documentation within emacs.

One strategy for single-stepping lisp programs is to step through the source program and evaluate the expressions one at a time. To evaluate the next expression after the cursor, type CONTROL-z n.


Editing Lisp in vi (if you insist)

Users of vi should issue the commands set sm to turn on matching parentheses and set ai for automatic indentation. Unfortunately, the automatic indentation mode is not smart enough to indent depending on the degree of nesting of the lisp expression, but at least it is a start.


Compiling Lisp

An interesting feature of GCL is that to compile lisp functions, it converts them to C and invokes the C compiler. Hence, the compiled files are ".o" files. GCL has extensive facilities for mixing C and lisp code in a single program.

However, in this course, you probably won't need to compile your functions, except for some of the highly search-intensive ones later in the quarter. Compiled functions are more brittle (e.g., most error checking is turned off), so it is definitely safer to use uncompiled functions until they are very mature and don't need further debugging.


Annoying Error Messages

GCL gives some annoying (but harmless) error messages.


Thomas G. Dietterich. Fri Sep 24 14:14:58 1999