CS 394P: Lisp Notes

Song: "God Wrote in Lisp", Lyrics by Bob Kanefsky, sung by Julia Ecklar.

Downloading and Using Lisp

Programming assignments are to be done in Lisp; see Using Lisp on Local Machines. Notes on Lisp Style and Efficiency are available. Common Lisp: the Language (second source) (third source) is a reference manual; also see ANSI and GNU Common Lisp Document

You can download Gnu Common Lisp for Linux or for Windows. Some macros for use with GCL are in macros.lsp

There are some on-line CS 307 lecture notes on the Scheme dialect of Lisp: by Contents or Index. There is also a page on differences between Scheme and Common Lisp.

Lisp is easier to use through the Emacs editor. Gnu Emacs can be dowloaded free, for either Linux or Windows. If you wish to use Gnu Common Lisp (GCL), you can copy the files /projects/cs394p/.emacs and /projects/cs394p/.lisp.el to your directory; these facilitate use of Lisp within emacs. You will also need to have /p/bin in your path, since xgcl is /p/bin/xgcl. This can be done by adding the following line to your .login file:

setenv PATH {$PATH}:/p/bin
Alternatively, you could put in a local link to xgcl with the following commands to unix:
ln -s /p/bin/xgcl ./xgcl
chmod +x xgcl

If you wish to use Allegro Common Lisp (ACL), see Using Lisp on Local Machines and copy Prof. Mooney's file instead.

To use Lisp within emacs, first start emacs . Then give the command C-x 3 (control-x 3) to split the window vertically into two halves (or C-x 2 (control-x 2) to split horizontally). With the cursor in one half-window, give the command M-x run lisp (meta-x run lisp) to start Lisp. You now can run Lisp within one window and edit your Lisp code in the other half. Putting your cursor at the start of a function definition in one window and giving the command C-M-z (control-meta-z) will send the definition to Lisp. You can also save your Lisp source code to a file and load the file from Lisp, e.g. (load "myfile.lsp") .

Program files are provided, in the directory /projects/cs394p/ or FTP directory for Program Files.

to be used with the assignments; these are described by Program File Descriptions.

Other Resources:

Increasing Stack Space

In Gnu Common Lisp (GCL), if the variable *multiply-stacks* is set to a positive fixnum, then the next time through the TOP-LEVEL loop, the loop will be exited. The size of the stacks will be multiplied by the value of *multiply-stacks*, and the TOP-LEVEL will be called again. Thus to double the size of the stacks:

   (setq si::*multiply-stacks* 2)
It is necessary to exit TOP-LEVEL, because it and other lisp functions maintain pointers into the stacks, which would be incorrect when the stacks have been moved. Interrupting the process of growing the stacks could leave Lisp in an inconsistent state.
Gordon S. Novak Jr.