Introduction
Common Lisp is the standardised dialect of Lisp, the family of languages begun by John McCarthy in 1958. It was published as ANSI standard X3.226 in 1994 and has several independent implementations, among them SBCL.
Source files are named .lisp, .lsp or .cl. A
project is described by an .asd file for the ASDF build system, and
compilers save their output as a fasl file.
Two of these extensions have other uses. .lsp is also used for AutoLISP
routines in AutoCAD, a separate dialect, and .cl is also used for OpenCL C,
the language of programs for graphics cards and other accelerators.
Structure
A Lisp file is plain text made of forms, which are parenthesised lists or single
values, read and evaluated one after another. The first word in a list is the operator.
; starts a comment to the end of the line and #| …
|# marks a block comment. The reader converts unquoted symbols to upper
case by default, so greet and GREET are the same symbol.
Files usually begin by defining or selecting a package with defpackage and
in-package. Named definitions follow, with defun for functions,
defvar and defparameter for variables,
defmacro for macros and defclass for classes. The
loop and format facilities are little languages of their
own. Reader macros, written with #, change how the text that follows is
read.
(defpackage :greeting
(:use :common-lisp))
(in-package :greeting)
;; Print a greeting, one line per name.
(defun greet (names)
"Print a greeting for each of NAMES."
(dolist (name names)
(format t "Hello, ~a~%" name)))
(greet '("Ada" "Grace"))
Links
Software
- SBCL – Steel Bank Common Lisp, a free compiler (Windows, macOS, Linux)
- Clozure CL – free Common Lisp (Windows, macOS, Linux)
- ECL – Embeddable Common Lisp, which compiles through C (Windows, macOS, Linux)
- LispWorks – commercial Common Lisp and development environment (Windows, macOS, Linux)
- SLIME – Emacs mode for developing Common Lisp interactively (Windows, macOS, Linux)
Developers
Reference
- Common Lisp HyperSpec – the standard in hypertext form
- CLiki – community wiki for Common Lisp
- ANSI INCITS 226-1994 – the standard, formerly X3.226