Skip to content

Common LISP

To start Common Lisp REPL instance we simply call the ‘clisp’ programme

To get back to the command line we use the lisp function (quit) or (exit)

We have 3 ways to interact with lisp code, the most basic is to use the REPL CLI and just type in lisp code. This is great to experiment with but does not really scale beyond a few lines. We therefore typically store our code in files with the .lisp extension. We can then load a lisp file either via a command line parameter or via the (load ‘filename.lisp’) function

On Linux-based systems we can also turn the lisp code into a script. This involves creating a shell script and including the location of the clisp runtime as the first line. We then make the script executable with the ‘chmod +x’ command

If during our REPL session we end up in the debugger then you can exit it back to the REPL CLI using CTRL-D

In our lisp code, we can use comments to add documentation

Let’s start with the basics of atoms and s-expressions. The fundamental building blocks of Lisp are word objects or atoms. A string on atoms (words) for a list and lists can consist of atoms and lists, refered to as s-expressions ( the s stands for symbolic). This is the structure of your code in Lisp

A macro is defined with the pre-processor directive. Macros are pre-processed which means that all the macros would be processed before your program compiles.

However, functions are not preprocessed but compiled

Common lisp has a fixed number of special forms ( currently 25 )