Skip to main content

readtable

readtable System Class

Class Precedence List:

readtable, t

Description:

A readtable maps characters into syntax types for the Lisp reader ; see Chapter 2 (Syntax). A readtable also contains associations between macro characters and their reader macro functions, and records information about the case conversion rules to be used by the Lisp reader when parsing symbols.

Each simple character must be representable in the readtable. It is implementation-defined whether non-simple characters can have syntax descriptions in the readtable.

See Also:

Section 2.1.1 (Readtables), Section 22.1.3.13 (Printing Other Objects)

Expanded Reference: readtable

The readtable system class

A readtable is an object that maps characters to syntax types for the Lisp reader. It also stores associations between macro characters and their reader macro functions, and records the case conversion mode for symbol reading.

;; *readtable* always holds a readtable object
(typep *readtable* 'readtable)
=> T

;; copy-readtable produces new readtable objects
(typep (copy-readtable) 'readtable)
=> T

Class precedence list

The class precedence list for readtable is: readtable, t.

(subtypep 'readtable t)
=> T
=> T

Readtables are not printed readably

Readtable objects have no standard printed representation that can be read back in. They print in an implementation-defined format.

;; The printed representation is implementation-dependent, typically something like:
;; #<READTABLE ...>
(readtablep (copy-readtable))
=> T

Key operations on readtables

The primary operations for working with readtables are copy-readtable, readtable-case, set-macro-character, get-macro-character, set-dispatch-macro-character, get-dispatch-macro-character, make-dispatch-macro-character, and set-syntax-from-char.

(let ((rt (copy-readtable)))
(list (readtable-case rt)
(null (get-macro-character #\( rt))
(null (get-macro-character #\a rt))))
=> (:UPCASE NIL T)
;; ( is a macro character, a is not