-->
LISP - Compiling in Unix

LISP - Compiling in Unix

LISP is an acronym for LISt Processor. It was developed by John McCarthy in the late 1950s, and his account of its history can be found at http://www-formal.stanford.edu/jmc/history/lisp/lisp.html. LISP found many adherents in the artificial intelligence community, and it is one of the oldest computer languages still in widespread use.[1]

There are many variants (or dialects) of LISP including Scheme, T, etc. In the 1980s there was an attempt to standardize the language. The result is Common LISP (see Guy L. Steele, Jr., Common LISP: The Language, 2nd Edition, Digital Press, 1990). Common LISP is now the most popular dialect. [1]

If you are familiar with another programming language, such as C, Pascal, or Fortran, you will be familiar with the concept of a compiler. A compiler is a program that takes a complete program written in one of these languages and turns it into a set of binary instructions that the computer can process. Unlike most languages, LISP is usually used as an interpreted language. This means that, unlike compiled languages, you start an interpreter which can process and respond directly to programs written in LISP.[1]

Here at the Computer Science department we use CMUCL a high-performance, free Common Lisp implementation. Lisp is located at /usr/local/bin/lisp on the departments unix machines.

Using LISP Interactively

  1. Open a Unix Session
  2. At the command prompt type:

    > lisp

  3. You will then be at a LISP prompt. To test that it is working type:

    * (print "Hello World")

    It should then print "Hello World" twice, once for your print statement and another time because of the return value for the expression.

  4. When you are finished with the LISP interpreter type the following to quit.

    * (quit)

    fig01
    Fig 01

Loading and Running a LISP file

  1. Use one of the following Unix editors to write your LISP program and save it.


  2. Then run lisp and tell it to load your source file.

    > lisp -load <your source file>.lsp

    Note: After running your source file it will drop into the LISP command interpretor, if you do not want this then add (quit) to the end of your source code.

Compiling a LISP program

Normally LISP programs are just interpreted on the fly, however in some cases when you are doing computationally intensive tasks there is a substantial speed increase if you compile your LISP programs.

  1. Open an interactive LISP session

    > lisp

  2. Then run the compile file command:

    * (compile-file "<your source file>.lsp")

  3. The compiled output will then be stored in <your lisp file>.sparcf

  4. To run your compiled lisp program:

    > lisp -load <your lisp file>.sparcf


[1] Introduction paragraphs are from the LISP Primer:
Allen, C, Dhagat, M. "LISP Primer". http://grimpeur.tamu.edu/~colin/lp/ accessed on 11/14/03


To Top of Page To Top Of Page Printer Friendly Version

©CSG Helpdesk

Valid CSS!