Computer Languages A to Z: Lisp
by Gary L. Ratliff, Sr. (eronstuc)
We have already had 2 previous articles in this series which have dealt with the language Lisp. The first was the E lisp dialect where in we were able to execute lisp forms from the scratch buffer of the Emacs editor. And then we had a discussion of using the Scheme Dialect from Guile.
Lisp, like Fortran, is one of the very first high level languages developed for computers, and like the early fate of Fortran, there soon developed many non-compatible dialects of the language.
The solution to this problem was the same as that for Fortran: have the language standardized. So the leading experts of the most used Lisp dialects met and selected the best features of these dialects, and agreed on a dialect called Common Lisp. However, the standard is very broad and there are features offered in the Common Lips products of the differing providers.
In this article, we will install and use three of these products: CLISP, Lispbox, and Lisp Works Personal Edition. We will demonstrate some very interesting features of these versions. Each of these has a separate set of documentation to explore.
Obtaining & Installing the Common Lisp Tools
The easiest to install is the CLISP version, which will be installed using synaptic. Simply perform a search for Lisp, mark the CLISP file for installation and click the Apply button. Once this has been installed, you will launch the program by entering the command clisp into an xterm or Konsole screen.
This will result in this display to show that the program has launched:
By far, the most difficult to install will be the free edition of the Lisp Works Personal Edition. These are the steps, as outlined on their website.
- Read the Release and Installation Notes.
- Download and run the Lisp Works license script.
- Download and install the Lisp Works software in one of these formats:
- RPM
- tar
- Download and install Open Motif version 2.2 or greater.
The Open Motif is obtained via the use of synaptic. The provided version will be 2.3. Perform a search for open motif and select openmotif. This will also download and install libopenmotif4. Because the system uses rpm type files, the easiest method will be to download the RPM version of the file. You can download the license script and the RPM file. They will go to the /home/username/Downloads/ folder.
Now become root and cd into this folder. All examples will use gary as the username:
su <enter root password> cd /home/gary/Downloads sh lwlper-license.sh (accept the terms by entering yes when asked then install) rpm -i lispworks-personal-5.1-1.i386.rpm cd /usr/bin (rename the file to lispw to make it easier to use) mv lispworks......... lispw (this actually creates a symbolic link to the executable) (Now when you first execute this file with lispw you learn that it is looking for a file named libXm.so.3 you will make version 4 of this library function by creating another symbolic link.) cd /usr/lib ln -s libXm.so.4 /usr/lib/libXm.so.3 exit
Now when we run the lispw command we should see the following:
The third product is Lispbox, which is a modification of the Lisp-in-a-box product designed to be used with the book Practical Common Lisp. This is available for several different versions of Lisp for the x86 Linux family: Allegro 8.1, SBCL, and CLISP 2.36. Now because the text in the book states that the examples are based on the Allegro implementation, this is the version we shall download We will find lispbox at the following website: http://gigamonkeys.com/lispbox/. Once here, you may wish to checkout the features offered. You may start the download by clicking on the line for the Allegro 8.1 version for i386 linux. This will place the file: lispbox-0.7-acl81-express.tar.gz to your /home/username/Downloads folder. The installation is to simply change to this directory and execute the command: tar xzvf lispbox<tab>. This action will create a directory named lispbox-0.7. Now simply cd into this directory and execute the command sh lispbox.sh. This action will produce this:
Another method, once the system has been setup, would be to move to the directory and click on the lispbox.sh item, which should appear as an icon.
The Documentation for these versions of Lisp
Now that these systems are installed, we will be ready to explore the documentation to learn how to use their features. If you check the Documentation section for the Lisp Works version, you will learn that the most recent set of files for the linux version was for 4.5. Since I installed the Windows and the linux versions, I just opted to use the pdf files from the Windows version for reading about the features of this system.
If you are not wanting to read a dry text version, there is even a comic book version in pdf format to teach the features of common lisp:
The book, which was designed to be used with the CLISP version, is called Loving Lisp, or the Savvy Programmer's Secret Weapon, by Mark Watson. You will find it at this web site: http://markwatson.com/opencontent/. Simply move to the bottom of the page and find the download link. This will produce a license to accept before the book is downloaded. The book is in zip format and should unzip into a pdf formatted text.
The book Practical Common Lisp is, of course, the documentation which will be used to explore the features of Lispbox. This book is 32 chapters and gives a thorough coverage of the dialect. It has several examples of how to use the features in making actual systems. The first two chapters provide a clue as to why you might wish to use Lisp as their main language.
As with other documentation, this may best be read using two different screens. Place the text of the chapter you are reading, and the Lisp-Emacs-Slime in the other. Then, as the text demonstrates the use of the features, it is easy for you to confirm the behavior and learn from the immediate feed back.
The chapter on the features offered by the format form are very interesting. This offers the ability to have very large numbers written out as cardinals and ordinals. Also it allows numbers to be expressed as Roman Numerals.
These are all accomplished with the r variable:
Note how the limit of the conversion to Roman numerals is 3999, as entering any number 4000 or larger just yields the number.
There is no lack of materials to help you with Common Lisp. Also available in the repositories are the Gnu Lisp version, available as GCL, and the Steel Bank Common Lisp compiler and runtime environment, which is in the repository as SBCL.
The above is what appears when you launch sbcl from a terminal.
Now for the final picture. Here is what appears when you launch Gnu Common Lisp with the command gcl.
When you consider that the list of functions available in common lisp is over 978 item long and requires 12 pages just to list, it should be obvious that this is just a brief introduction to the world of Lisp programming.