Lisp Interpreter · Library

Ditty

An embeddable Lisp interpreter and syntax highlighter written in C — with packages, a condition system, tail-call optimization, and a REPL.

#library #c #cli #interpreter #language #lisp #scripting

What is Ditty?

Ditty is a Lisp dialect implemented as an embeddable C library. It follows traditional Lisp naming conventions and ships a standalone interpreter, an interactive REPL, and Flare — a built-in syntax highlighter. The core library links only against libc, Boehm GC, and PCRE2; it has no dependency on a UI toolkit.

It powers the scripting layer of mudlark, the MUD/telnet client, and the TUI REPL optionally builds on boba for an interactive terminal experience.

Features

  • Embeddable static library (libditty.a) with a pkg-config file
  • Package system and a condition (error-handling) system
  • Tail-call optimization
  • Macros and special forms via an X-macro single source of truth
  • Flare syntax highlighter + a flare CLI
  • Interactive REPL (ditty) with a TUI mode
  • Emacs major mode (ditty-mode) with ERT tests
  • Canonical source formatter (lisp-fmt)

Build & install

git clone https://github.com/chestso/ditty
cd ditty
./autogen.sh
mkdir -p build && cd build
../configure --prefix=$HOME/.local
make -j"$(nproc)"
make install

To embed: link against libditty.a and use the lisp_* public API. See the Language Guide for the full language documentation, and the Built-in Function Reference for per-function details and examples.

A quick taste

$ ditty
ditty> (define (fact n) (if (= n 0) 1 (* n (fact (- n 1)))))
ditty> (fact 10)
3628800