EECS 325: Setting up Lisp

Download and install Common Lisp

Two versions of Common Lisp are recommended for this class. Both are free,
and both are mature systems.

The free (Express) version of
Franz, Inc.'s Allegro Common Lisp .
The Windows version includes a graphics development environment. The
MacOS version has an IDE that uses the X11 Windowing system.
For Unix, Franz recommends SLIME
as an IDE. This is beyond the scope
of this tutorial.

The free (personal) version of Lispworks.
This provides a graphical IDE for Windows, MacOS, and GTK+ (Linux).

SBCL is popular with Unix users.
It is open-source and doesn't have the memory / time limitations that the free versions of
Allegro and Lispworks do.

I do not recommend SBCL for this course.
Support is particularly weak on Windows and MacOS. SBCL forces Unix line endings
onto code files on Windows, has to be re-built from source to get multithreading
on MacOS, just plain doesn't seem to support the portable AllegroServe web server, and
doesn't provide a user-friendly Lisp-savvy editor out of the box.

You must use a Lisp-savvy editor that knows how to
correctly indent Lisp. If you try to indent by hand, you will get it wrong.
I immediately return incorrectly indented Lisp code to be fixed.

Be sure to use the extension .lisp for all
Lisp source files. Many Lisp integrated development environments (IDEs),
like other IDEs, use the extension to determine what indentation rules to
use.

Scheme is not suitable for this course.

Install QuickLisp

QuickLisp is a Lisp
library that makes it easy to download
and install other libraries.

QuickLisp depends on
ASDF files to define Lisp "systems." A Lisp system is
what other languages call a library or module, i.e., a set of files, and a list of
any other systems that this system depends on.

Download quicklisp.lisp into some directory that is easy to find.

Check for two common mistakes:

Be sure the file is saved with the extension is lisp.
Browsers often want to save this file as quicklisp.lisp.txt instead.
That won't work. Rename the file if this happened.

Be sure the file doesn't contain HTML. Some browsers add HTML code when you
do "Save As..." If this happens, try a different approach to
downloading the file. The file should only contain Lisp code.

Start Lisp

Load quicklisp.lisp using the File | Load
command in your Lisp. This file does not need to be compiled.

In the Listener, evaluate

(quicklisp-quickstart:install)

This operation will download the files that QuickLisp needs. You will not need to do
this in the future. If there are any errors, ask for help.

Do not call ql:add-to-init-file as described on the QuickLisp page. The instructions below
will take care of that part.

Don't quit Lisp yet.

Upgrade ASDF

QuickLisp will check for and install ASDF2 if your Lisp doesn't ASDF already. Unfortunately, some
libraries these days want ASDF3, so we need to upgrade.

In Lisp, the global variable *features* is a list of names of installed
features. To see if ASDF3 is installed already in your Lisp, execute this line of code in your
Lisp listener window:

(member :asdf3 *features*)

If it returns nil, you need to upgrade. If it returns a list, you can skip this step.

Several files need to be replaced in the QuickLisp directory, ~/quicklisp/, and a
subdirectory needs to be cleared.

This should cause an updated ADSF3 to be loaded when you restart Lisp,
after you do the remaining setup tasks.

On Unix and MacOS, the file syntax ~/quicklisp/ refers to
the quicklisp subdirectory in
your home directory.
On Windows XP and later, the equivalent way to write this is
%USERPROFILE%\quicklisp\. For brevity,
we'll use Unix syntax. In Lisp code, use the Unix syntax to refer to files
and directories. That works on all platforms.

Don't quit Lisp yet.

Install the CS325 Library

There are a number of Lisp tools used in this class. They are
set up as a QuickLisp local project.

SBCL on Windows only: SBCL uses Unix line endings,
even on Windows, a major SBCL bug IMO. This breaks
the Lisp Critic rule file, lisp-rules.lisp.
To fix, you need to convert lisp-rules.lisp
to Unix line endings with some
utility, such as dos2unix. Convert that file before continuing.
You will need to do this whenever I release updates to the rule file.

Now, in Lisp, tell Quicklisp to update its list of projects, then try loading the 325 code.

> (ql:register-local-projects)
...
> (ql:quickload "cs325")
...

If everything is set up correctly, a number of files will be compiled and loaded. Compiling
happens only when a file is added or changed. Future loads will be much quicker.

If you see any messages labeled ERROR, stop and check the
messages to see if you can determine the problem. If you can't,
post your problem. Be sure to include what Lisp and
operating system you are using, along with the exact error message, copied
and pasted.

If you see compiler messages labeled warnings, these may be OK. Continue.

Set Up Your Init File

You now have at least two things you want to do every time you start Lisp:

Load ~/quicklisp/setup.lisp

Run (ql:quickload "cs325")

In addition, in each Lisp there are some platform-specific options you can customize that will
make things more convenient.

Most Lisps load one or more initialization files with Lisp code when they start.
The location and contents of these files depends on your specific Lisp. I have created
initialization files for several Lispyour home directory.