2 Starting Up

2.2 Sample Lisp program

The sample program displayed below demonstrates how Lisp programs are written and used. The program creates a queue, a buffer to which you can add or remove items. It implements functions to make a queue, to add and remove elements, and to check if the queue is empty.

The source code for the program is in the file"queue.lisp". The procedures defined in the program become available for use when"queue.lisp" is loaded into the current Lisp image.

This sample program illustrates the use of data abstraction in Lisp. The procedures to add and remove elements of the queue are independent of the implementation of the queue. The queue itself is implemented as a structure, a data object with a series of named slots. Lisp automatically creates functions to construct, access, and copy instances of a structure.

The source code demonstrates some basic characteristics of good programming style in Lisp, such as using documentation strings to document procedures and indenting the source code to make it easier to read. The source code also includes type information that allows the Compiler to generate more efficient compiled code.

2.2.1 - The program file
2.2.2 - Terminal session

The User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker