Can you help me to rapidly learn common lisp, emacs, and SLY? Here’s what I want to do and want a short manual for:
- A brief description of SBCL and what the binary does
- A brief description of quicklisp and how the system works
- A brief description of SLY (the EMACS repl) and where it fits in
- A hello-world example written with sly and emacs
- Showing how to compile this hello-world to an executable on Debian
All content below is the response to this request.
Common Lisp, SBCL, Quicklisp, and SLY: A Beginner’s Guide¶
1. What is SBCL?¶
SBCL (Steel Bank Common Lisp) is a high-performance Common Lisp compiler and runtime. The sbcl
binary is used to:
- Start an interactive Lisp REPL (Read-Eval-Print Loop).
- Compile and run Lisp programs.
- Build standalone executables.
To install SBCL on Debian:
sudo apt install sbcl
You can start the REPL by typing:
sbcl
2. What is Quicklisp?¶
Quicklisp is a package manager for Common Lisp, similar to pip
for Python. It simplifies library management.
Installing Quicklisp¶
Run the following in your terminal:
curl -O https://beta.quicklisp.org/quicklisp.lisp
sbcl --load quicklisp.lisp
Then, in the SBCL REPL:
(quicklisp-quickstart:install)
(ql:add-to-init-file) ;; Makes Quicklisp available in future sessions
Using Quicklisp¶
Load a library (e.g., cl-ppcre
for regex):
(ql:quickload "cl-ppcre")
3. What is SLY?¶
SLY (Superior Lisp Interaction Mode for Emacs) is an Emacs extension for working with Lisp. It provides:
- A powerful REPL.
- Code navigation and debugging.
- Integration with SBCL.
Installing SLY in Emacs¶
- Open Emacs and run:
M-x package-install RET sly RET
- Add this to your
~/.emacs
:(setq inferior-lisp-program "sbcl") (require 'sly)
- Start SLY with:
M-x sly
4. Hello-World in SLY and Emacs¶
- Open Emacs.
- Create a file
hello.lisp
:(defun hello-world () (format t "Hello, world!~%"))
- Load the file in SLY:
Then, inside the SLY REPL:M-x sly
(load "hello.lisp") (hello-world)
5. Compiling to an Executable on Debian¶
To compile your Lisp program into a standalone binary:
- Create
hello.lisp
with:(defun main () (format t "Hello, world!~%")) (sb-ext:save-lisp-and-die "hello" :toplevel #'main :executable t)
- Compile it with SBCL:
sbcl --script hello.lisp
- Run the generated binary:
./hello
This should get you started! Let me know if you need refinements or additions. 🚀