Project:Common Lisp/Guide

From Gentoo Wiki
Jump to: navigation, search



This guide is a draft. Use it with caution! The Gentoo Common Lisp team is slowly working on a new one.
This guide describes the use of Common Lisp in Gentoo Linux for those using ~arch keywords.


One of the great things about Common Lisp is the variety of quality implementations available. Gentoo Linux supports the following free software implementations:

Lisp implementations
Implementation Homepage
dev-lisp/abcl Armed Bear Common Lisp
dev-lisp/clisp CLISP
dev-lisp/clozurecl Clozure Common Lisp
dev-lisp/cmucl CMU Common Lisp
dev-lisp/ecls Embeddable Common Lisp (ECL)
dev-lisp/gcl GNU Common Lisp (GCL)
dev-lisp/sbcl Steel Bank Common Lisp


As of writing, there are over two-hundred Common Lisp libraries supported in Gentoo Linux. All Common Lisp libraries in Gentoo are made available within the dev-lisp category in the Gentoo repository and the dev-lisp category in the lisp overlay

Using Common Lisp

Create a Gentoo Common Lisp initialization file somewhere in your home directory. You might call the file gentoo-init.lisp perhaps. You could include this initialization code directly in your Lisp implementation's initialization file (eg. ~/.sbclrc, ~/.clisprc, ~/.cmucl-init.lisp etc.), but it will make more sense to include it from an external file if you work with more than one implementation. The first thing our initialization code must do is load ASDF:

CODE Loading ASDF from gentoo-init.lisp
(in-package #:cl-user)
#+(or sbcl ecl) (require :asdf)
#-(or sbcl ecl) (load #p"/usr/share/common-lisp/source/asdf/asdf.lisp")

If the implementation includes ASDF then you may need to load it using the implementation a specific REQUIRE. If the implementation doesn't include ASDF then we load it directly. The next step is to configure ASDF to use the Portage-installed Common Lisp libraries:

CODE Configuring ASDF
(push #p"/usr/share/common-lisp/systems/" asdf:*central-registry*)

Portage currently creates a directory of symlinks /usr/share/common-lisp/systems/ which point to ASDF system definition files (*.asd) in /usr/share/common-lisp/source/ rather than adding a path to each individual ASDF system definition file.

The following examples show how to use gentoo-init.lisp from various Common Lisp implementations. Note how ASDF system definitions are being found under /usr/share/common-lisp/systems/ and compiled to, for example, /home/larry/.fasls/sbcl-1.3.21-linux-x86/usr/share/common-lisp/source/....

From SBCL:

This is SBCL 1.3.21, an implementation of ANSI Common Lisp.
More information about SBCL is available at <>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* (load "gentoo-init")


[1]> (load "gentoo-init")
;; Loading file /home/larry/gentoo-init.lisp ...
;;  Loading file /usr/share/common-lisp/source/asdf/asdf.lisp ...
;;  Loaded file /usr/share/common-lisp/source/asdf/asdf.lisp

The Gentoo-Maintained gentoo-init.lisp

Now that you understand how integration of Common Lisp implementations and libraries is achieved in Gentoo, you might want to install the ready-made dev-lisp/gentoo-init which will install gentoo-init.lisp to /etc/gentoo-init.lisp for you. You could then load the file from your implementation's initialization file.

CODE Loading /etc/gentoo-init.lisp
(when (probe-file #p"/etc/gentoo-init.lisp")
  (load #p"/etc/gentoo-init.lisp"))