Project:Common Lisp/Guide

From Gentoo Wiki
Jump to:navigation Jump to:search

This guide describes the use of Common Lisp in Gentoo Linux for those using unstable (~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/ecl 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

You will need to install dev-lisp/asdf if you are planning to use Common Lisp packages or build software. Most implementations will pull that package when installed. If ASDF is not getting installed you can do it as usual

root #emerge --ask dev-lisp/asdf

Next, 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 your gentoo-init.lisp
(when (probe-file #p"/etc/common-lisp/gentoo-init.lisp")
    (load #p"/etc/common-lisp/gentoo-init.lisp"))

Portage 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 so any package can be REQUIRE'd:

This is SBCL 1.4.7, 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.
* (require :linedit)

; compiling file "/usr/share/common-lisp/source/alexandria/types.lisp" (written 22 MAR 2018 10:20:39 AM):
; compiling (DEFTYPE ARRAY-INDEX ...)
; compiling (DEFTYPE ARRAY-LENGTH ...)
; compiling (FROB FIXNUM ...)
; compiling (FROB INTEGER)
; compiling (FROB RATIONAL)
; compiling (FROB REAL)
; compiling (FROB FLOAT)
; compiling (FROB SHORT-FLOAT)
; compiling (FROB SINGLE-FLOAT)
; compiling (FROB DOUBLE-FLOAT)
; /home/larry/.cache/common-lisp/sbcl-1.4.7-linux-x64/usr/share/common-lisp/source/linedit/command-functions-tmpOOSRA8PZ.fasl written
; compilation finished in 0:00:00.132
; compiling file "/usr/share/common-lisp/source/linedit/ports/sbcl.lisp" (written 28 MAY 2018 07:12:09 PM):
; compiling (IN-PACKAGE :LINEDIT)
; compiling (LET (PROMPT-FUN READ-FORM-FUN) ...)

; /home/larry/.cache/common-lisp/sbcl-1.4.7-linux-x64/usr/share/common-lisp/source/linedit/ports/sbcl-tmpDMIL0RVK.fasl written
; compilation finished in 0:00:00.052
; compilation unit finished
;   printed 11 notes