<astyle="font-size: 120%"href="https://www.udemy.com/course/common-lisp-programming/?couponCode=LISPY-XMAS2023"title="This course is under a paywall on the Udemy platform. Several videos are freely available so you can judge before diving in. vindarel is (I am) the main contributor to this Cookbook."> Discover our contributor's Lisp course with this Christmas coupon.</a>
<li><ahref="http://abcl.org/">ABCL</a>, to interface with the JVM,</li>
<li><ahref="https://ccl.clozure.com/">ClozureCL</a>, a good implementation with very fast build times (see this <ahref="http://mr.gy/blog/clozure-cl-deb.html">Debian package for Clozure CL</a>),</li>
<li><ahref="https://github.com/drmeister/clasp">CLASP</a>, that interoperates with C++ libraries using LLVM for compilation to native code,</li>
<li><ahref="https://gitlab.common-lisp.net/cmucl/cmucl">CMUCL</a>, originally developed at Carnegie Mellon University, from which SBCL is derived, and</li>
<li><ahref="https://en.wikipedia.org/wiki/GNU_Common_Lisp">GNU Common Lisp</a></li>
<li>and there is more!</li>
</ul>
<h3id="with-the-asdf-vm-package-manager">With the asdf-vm package manager</h3>
<p>The <ahref="http://asdf-vm.com/">asdf-vm</a> tool can be used to manage a large ecosystem of runtimes and tools.</p>
<ul>
<li><ahref="http://www.sbcl.org/">Steel Bank Common Lisp (SBCL)</a> is available via <ahref="https://github.com/smashedtoatoms/asdf-sbcl">this plugin</a> for <ahref="http://asdf-vm.com/">asdf-vm</a></li>
which is a library that helps on setting that up.</p>
<h3id="on-windows">On Windows</h3>
<p>All implementations above can be installed on Windows.</p>
<p><ahref="https://shinmera.github.io/portacle/">Portacle</a> is multiplatform and works on Windows.</p>
<p>You can also try:</p>
<ul>
<li><ahref="https://rho-emacs.sourceforge.io/">ρEmacs</a>, a preconfigured distribution of GNU Emacs specifically for Microsoft Windows. It ships with many CL implementations: CCL, SBCL, CLISP, ABCL and ECL, and also has components for other programming languages (Python, Racket, Java, C++…).</li>
<li><ahref="https://github.com/sharplispers/cormanlisp">Corman Lisp</a>, for Windows XP, Windows 2000, Windows ME or Windows NT. It is fully integrated with the Win32 API, and all the Windows API functions are readily available from Lisp.</li>
</ul>
<h2id="start-a-repl">Start a REPL</h2>
<p>Just launch the implementation executable on the command line to enter
the REPL (Read Eval Print Loop), i.e. the interactive
interpreter.</p>
<p>Quit with <code>(quit)</code> or <code>ctr-d</code> (on some implementations).</p>
<p>Here is a sample session:</p>
<pre><code>user@debian:~$ sbcl
This is SBCL 1.3.14.debian, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
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.
* (+ 1 2)
3
* (quit)
user@debian:~$
</code></pre>
<p>You can slightly enhance the REPL (the arrow keys do not work,
it has no history,…) with <code>rlwrap</code>:</p>
<pre><code>apt-get install rlwrap
</code></pre>
<p>and:</p>
<pre><code>rlwrap sbcl
</code></pre>
<p>But we’ll setup our editor to offer a better experience instead of
working in this REPL. See <ahref="editor-support.html">editor-support</a>.</p>
<p>Lisp is interactive by nature, so in case of an error we enter the
debugger. This can be annoying in certain cases, so you might want to
use SBCL’s <code>--disable-debugger</code> option.</p>
<strong>SEE MORE:</strong> To understand the <code>package:a-symbol</code> notation, read the <ahref="packages.html">packages page</a>, section "Accessing symbols from a package".
</div>
<p>We can install more than one library at once. Here we install
<ahref="https://edicl.github.io/cl-ppcre/">cl-ppcre</a> for regular-expressions, and
<p>Anytime you want to use a third-party library in your Lisp REPL, you
can run this <code>ql:quickload</code> command. It will not hit the network a second
time if it finds that the library is already installed on your file
system. Libraries are by default installed in
<code>~/quicklisp/dist/quicklisp/</code>.</p>
<p>Note also that dozens of Common Lisp libraries are packaged in
Debian. The package names usually begin with the cl- prefix (use
<code>apt-cache search --names-only "^cl-.*"</code> to list them all).</p>
<p>For example, in order to use the <code>cl-ppcre</code> library, one should first install the <code>cl-ppcre</code> package.</p>
<p>Then, in SBCL, it can be used like this:</p>
<pre><codeclass="language-lisp">(require "asdf")
(require "cl-ppcre")
(cl-ppcre:regex-replace "fo+" "foo bar" "frob")
</code></pre>
<p>Here we pretend we don’t have Quicklisp installed and we use <code>require</code> to load a module that is available on the file system. In doubt, you can use <code>ql:quickload</code>.</p>
<p>See Quicklisp’s documentation for more commands. For instance, see how to upgrade or rollback your Quicklisp’s distribution.</p>
<li>ASDF documentation: <ahref="https://common-lisp.net/project/asdf/asdf.html#Defining-systems-with-defsystem">defining a system with defsystem</a></li>
</ul>
<h3id="how-to-load-an-existing-project">How to load an existing project</h3>
<p>You have created a new project, or you have an existing one, and you
want to work with it on the REPL, but Quicklisp doesn’t know it. How
can you do ?</p>
<p>Well first, if you create it or clone it into
one of <code>~/common-lisp</code>, <code>~/.local/share/common-lisp/source/</code> or
<code>~/quicklisp/local-projects</code>, you’ll be able to <code>(ql:quickload …)</code> it with no
further ado.</p>
<p>Otherwise you’ll need to compile and load its system definition
(<code>.asd</code>) first. In SLIME with the <code>slime-asdf</code> contrib loaded, type <code>C-c C-k</code>
(<em>slime-compile-and-load-file</em>) in the <code>.asd</code>, then you can
<code>(ql:quickload …)</code> it.</p>
<p>You can use <code>(asdf:load-asd "my-project.asd")</code> programmatically instead of <code>C-c C-k</code>.</p>
<p>Usually you want to “enter” the system in the REPL at this stage:</p>
<li><ahref="https://github.com/vindarel/cl-cookieproject">cl-cookieproject</a> - a project skeleton for a ready-to-use project with an entry point and unit tests. With a <code>src/</code> subdirectory, some more metadata, a 5AM test suite, a way to build a binary, an example CLI args parsing, Roswell integration.</li>
<li>Source code organization, libraries and packages: <ahref="https://lispmethods.com/libraries.html">https://lispmethods.com/libraries.html</a></li>