Slime

Automate and integrate Slime workflows for flexible and dynamic data management tasks

SLIME is a community skill for Common Lisp development using SLIME (Superior Lisp Interaction Mode for Emacs), covering REPL interaction, code evaluation, debugging, inspection, and interactive development workflows for Lisp programming.

What Is This?

Overview

SLIME provides tools for interactive Common Lisp development with direct connection to a running Lisp process. It covers REPL interaction that evaluates expressions and displays results with history navigation, code evaluation that sends forms from source buffers to the connected Lisp for immediate execution, debugging that inspects stack frames, restarts, and conditions when errors occur, inspection that examines Lisp objects with interactive browsing of slots and references, and interactive development that supports incremental compilation and hot code reloading. The skill helps Lisp developers work interactively.

Who Should Use This

This skill serves Common Lisp developers using Emacs as their editor, researchers working in symbolic AI and knowledge systems, and programmers learning Lisp through interactive exploration.

Why Use It?

Problems It Solves

Edit-compile-run cycles are slow for exploratory programming where quick feedback is essential. Debugging compiled Lisp code requires understanding the condition system and restart mechanism. Inspecting complex Lisp data structures in a text REPL is cumbersome. Managing multiple Lisp packages and systems during development needs tool support.

Core Highlights

REPL connector evaluates expressions with result history. Code sender executes forms directly from source buffers. Debugger inspector navigates stack frames and restarts. Object browser examines Lisp data structures interactively.

How to Use It?

Basic Usage

;; SLIME interactive
;; development

;; Define a function at
;; the REPL
(defun factorial (n)
  "Compute n factorial."
  (if (<= n 1)
      1
      (* n (factorial
              (1- n)))))

;; Test interactively
(factorial 10)
;; => 3628800

;; Define a generic
;; function
(defgeneric area (shape)
  (:documentation
    "Compute shape area."))

(defclass circle ()
  ((radius
    :initarg :radius
    :reader radius)))

(defmethod area
  ((c circle))
  (* pi (expt
    (radius c) 2)))

(defclass rectangle ()
  ((width
    :initarg :width
    :reader width)
   (height
    :initarg :height
    :reader height)))

(defmethod area
  ((r rectangle))
  (* (width r)
     (height r)))

;; Use immediately
(area (make-instance
  'circle :radius 5))
;; => 78.53981633974483

Real-World Examples

;; Data processing with
;; SLIME inspection

(defstruct person
  name age email)

(defun load-people
  (data)
  "Parse list of plists
   into person structs."
  (mapcar
    (lambda (entry)
      (make-person
        :name (getf entry
                :name)
        :age (getf entry
               :age)
        :email (getf entry
                 :email)))
    data))

(defun filter-adults
  (people min-age)
  "Filter people by
   minimum age."
  (remove-if-not
    (lambda (p)
      (>= (person-age p)
          min-age))
    people))

(defun summarize
  (people)
  "Summarize people data."
  (let ((ages
          (mapcar
            #'person-age
            people)))
    (list
      :count (length ages)
      :avg-age
        (float
          (/ (reduce
               #'+ ages)
             (length
               ages))))))

;; Interactive workflow
(defvar *people*
  (load-people
    '((:name "Alice"
       :age 30
       :email "a@ex.com")
      (:name "Bob"
       :age 25
       :email "b@ex.com")
      (:name "Carol"
       :age 35
       :email
         "c@ex.com"))))

(summarize
  (filter-adults
    *people* 28))

Advanced Tips

Use the SLIME inspector to navigate complex nested data structures by clicking on object references. Compile individual functions with C-c C-c for incremental development without reloading entire files. Set up multiple Lisp connections to test code across different implementations.

When to Use It?

Use Cases

Develop and test Common Lisp functions interactively with immediate feedback at the REPL. Debug a condition by examining stack frames and choosing appropriate restarts. Inspect complex data structures during development using the interactive object browser.

Related Topics

Common Lisp, Emacs, REPL-driven development, interactive debugging, SLIME, CLOS, and incremental compilation.

Important Notes

Requirements

Emacs editor with SLIME package installed from MELPA or Quicklisp. Common Lisp implementation such as SBCL, CCL, or ABCL for the backend process. Familiarity with Emacs keybindings for efficient SLIME interaction.

Usage Recommendations

Do: use incremental compilation to test changes immediately without restarting the Lisp process. Take advantage of the condition system and restarts for interactive error recovery. Explore unfamiliar objects using the inspector before writing code that depends on their structure.

Don't: ignore compiler warnings since Common Lisp provides useful diagnostics for type mismatches and undefined references. Restart the Lisp process for every change since SLIME supports hot reloading. Write large functions without testing components interactively at the REPL.

Limitations

SLIME is tightly coupled to Emacs and does not support other editors natively. The learning curve includes both Common Lisp concepts and Emacs keybinding conventions. Some SLIME features depend on the specific Lisp implementation and may behave differently across backends.