The VikiD Truth

Knowledge base / Computing / Lisp family

PicoLisp Sources

The plain idea

PicoLisp has been implemented three times. This page is the index of my reading of all three, updated in October 2026:

Why read interpreter sources at all?

Because PicoLisp is small enough to read. All of pil21’s src/*.l is about 16,000 lines. You can see exactly how a cell is laid out, how a symbol stores its value and properties, how the garbage collector marks, and how eval walks a list. See The PicoLisp Machine for the data model.

An analogy

Reading a novel tells you the story. Reading the author’s drafts tells you how stories are built. These pages are the drafts.

The pil21 source tree (src/)

From pil21.tgz, version 26.9:

FileWhat it holds
lib/llvm.lThe LLVM front end: a PicoLisp DSL that emits LLVM IR. Everything else is written in it.
vers.lThe version, (pico~de *Version 26 9 25). See vers.l.
defs.l, glob.l, dec.lConstants, global symbols and the symbol table, and declarations.
main.lStartup, the REPL, eval/apply, error handling, signals.
gc.lThe mark-and-sweep garbage collector and heap.
big.lNumbers: short numbers and bignums, arithmetic.
sym.lSymbols, names, namespaces, properties, list functions.
io.lThe reader, printer, files, sockets and pipes.
db.lExternal symbols: the database engine.
apply.l, flow.l, subr.lFunction application, control flow (if, loop, co…), and list built-ins.
ext.l, ht.lThe ext.so and ht.so extension libraries (ht.so speeds up HTTP and HTML output).
lib.c, pico.hA small C helper layer for things easier done in C (terminal, signals, native calls). See pico.h.
httpGate.c, ssl.c, balance.c, sysdefs.cStandalone tools in C: the HTTPS proxy (httpGate), the SSL client, a load balancer, and the generator for lib/sysdefs.
MakefileBuilds it all with clang, opt, llc and llvm-link. See Makefile.

A built-in function in pil21 looks like this (from src/subr.l):

# (cdr 'lst) -> any
(de _Cdr (Exe)
   (chkD (eval (cadr Exe))) )

That is PicoLisp code, but it is compiled, not interpreted: lib/llvm.l turns it into LLVM IR (base.ll), and LLVM optimises it into machine code. The tarball ships the generated .ll files, so you can build pil21 without having PicoLisp installed first.

How to use this page

For today’s PicoLisp, start with src/defs.l and src/glob.l for the data structures, then main.l for evaluation, then sym.l and subr.l. Read the reference VM section alongside.

For the historical C version, start with pico.h, then main.c and flow.c to see evaluation, then sym.c and subr.c for symbols and lists.

Examples Examined

Libraries (current)

32 Bit C Source (pil32, archive)

These are my 2017 reading notes on the pil32 sources, kept as they were:

64 Bit Asm Source (pil64, archive)

Last edited · 24 revisions

Tags: #Computing