Define a recognizer for a particular set of characters.
Defcharset is a macro for introducing a charset-p and
proving that it recognizes the correct characters.
(or (eql x #\Newline)
(eql x #\Space)
(eql x #\Tab)))
This example introduces:
- (whitespace-char-p x) — a "slow" function for recognizing
newline, space, and tab characters
- (whitespace-chars) — a charset-p that is proven to
correspond to whitespace-char-p,
- (whitespace-charlist-p x) — an ordinary std::deflist to
recognize lists whose every character satisfies whitespace-char-p.
(defcharset prefix criteria
All functions will be introduced in pkg, determined as follows:
- If an :in-package-of argument is provided, then the corresponding
package must be a symbol, and we will use its package.
- Otherwise, the package of prefix will be used.
The prefix is a symbol that is used for name generation. Some common
examples would be whitespace, alpha, digit, etc.
The criteria is some term involving the variable pkg::x. The
criteria term may assume that x is a character, and is responsible for
determining whether x is a member of the desired set. Normally you should
not worry about the efficiency of criteria. Although the term you write
here does become part of recognizers like whitespace-char-p and
whitespace-charlist-p, the actual character set, i.e.,
whitespace-chars, is represented as a bit mask, and the speed of your
criteria term will not have any bearing on how fast it is to look up its
The :parents, :short, and :long options are as in defxdoc, and allow you to provide documentation to the character recognizer,
e.g., whitespace-char-p. The other functions are documented