Named-readtables — Readtable Management for Common Lisp
Table of Contents
Definition
named-readtables is a Common Lisp library that gives names to readtables,
allowing them to be selected per-file with in-readtable. The standard CL
readtable is a mutable global object; named-readtables provides a safe,
modular alternative.
Online documentation: github.com/melisgl/named-readtables
How It Is Used in Tolk
Tolk uses named-readtables to activate the :fare-quasiquote readtable,
which extends the standard quasiquote syntax to be usable as a trivia pattern.
Every tolk source file that uses quasiquote patterns declares:
(named-readtables:in-readtable :fare-quasiquote)
This is a per-file declaration (like in-package). It affects only the file
in which it appears. Other files retain the standard readtable unless they
also declare in-readtable.
Mechanism
in-readtable sets *readtable* to the named readtable for the duration of
loading the current file. This means any reader-macro extensions registered
under that name are active when the file's forms are read.
fare-quasiquote registers itself under the name :fare-quasiquote by
calling named-readtables:defreadtable.
Loading
(ql:quickload :named-readtables)
trivia.quasiquote loads named-readtables and fare-quasiquote
automatically as dependencies.
Related
- Fare-quasiquote — the readtable that named-readtables activates in tolk
- Trivia — the pattern-matching library that uses the extended readtable
- Tolk — declares
in-readtable :fare-quasiquotein each parser file