# Semantics: the supported Lisp subset

This is not a conforming Common Lisp. The lists below are exhaustive for the current milestone.

## Implemented

The deprecated host methods `eval_in` and `eval_in_values` accept only empty
scopes and use the compiled machine. A non-empty host-built scope returns
`NotImplemented`; use Lisp `LET` or globals to bind host values (ADR 0070).

- Exact integers (immediate i64 fixnums, heap bignums) and normalized ratios such as `-3/4`; self-evaluating (ADR 0057).
- **Multiple values (M14).** Evaluation yields a packet of zero or more values. Zero values
  (`(values)`) are distinct from one `NIL` (`(values nil)`). A single-value context uses the first
  value, or `NIL` if there are none: call arguments, `IF` tests, `LET` / `&OPTIONAL` / `&KEY` /
  `&AUX` inits, `SETQ` RHS, `DEFVAR`/`DEFPARAMETER` inits, `CATCH`/`THROW` tags, and the public
  host methods `eval` / `eval_in` / `eval_str` / `apply` / `eval_to_string`. Propagation contexts
  (selected `IF` branch, final `PROGN`/body form, function/`FUNCALL`/`APPLY` return, `BLOCK`/`CATCH`
  completion, evaluation of a macro expansion, `UNWIND-PROTECT` protected result) keep the complete
  packet. Empty `PROGN`, a missing `IF` else, an omitted `RETURN-FROM` result, `(setq)` and `(setf)` remain
  **one `NIL`**, never zero values. `SETQ` and `SETF` each return exactly one value (the last assigned
  / stored primary).
  - **`VALUES`:** ordinary builtin function, not a special operator. Callable via `FUNCALL`/`APPLY`.
    Ordinary arguments consume primary only, so `(values (values 1 2) 3)` is two values.
  - **`MULTIPLE-VALUE-CALL`:** protected special operator. Evaluates the function form as a primary
    value, concatenates every value of each producer (a zero-value producer contributes no argument),
    applies the function, and propagates the callee's packet. Count is capped at `MAX_CALL_ARGUMENTS`.
  - **`MULTIPLE-VALUE-PROG1`:** protected special operator. The first form's complete packet is
    saved; later forms run in discard context. A later transfer or error abandons the saved packet.
    Later forms do not run if the first form transfers or errors.
  - **`MULTIPLE-VALUE-BIND`:** protected native derived form (ANSI macro). rustlisp implements it
    natively. `GENSYM` exists (M43); this form has not been moved to a Lisp macro.
    Variables are symbols (constants and duplicates rejected as in `LET`); missing values bind `NIL`;
    excess values are ignored. Body `(declare (special ...))` follows the M13B `LET` rules. The
    values-form is outside declaration scope. The body's final form propagates its packet.
  - **`VALUES-LIST`:** Layer 0 `(defun values-list (list) (apply #'values list))`. Redefinable.
    Improper or cyclic lists follow `APPLY`.
  - **`MULTIPLE-VALUE-LIST`:** Layer 0 macro over `MULTIPLE-VALUE-CALL` of `LIST`. Returns exactly
    one list. Redefinable.
  - Host `eval_values` / `eval_in_values` / `eval_str_values` / `apply_values` return the packet.
    A returned packet is not a persistent GC root; `host_root_values` registers every member.
    The REPL prints each returned value on its own line; zero values print no result line.
    `-e` stays primary-only.
  - **`NTH-VALUE` (M53):** Layer 0 macro, absent on the bare kernel, redefinable.
    `(nth-value n form)` evaluates `n`, then `form`, and returns the zero-based
    value. Only the primary value of `n` is the index. A missing value is `NIL`,
    including when `form` returns no values. A bad index is `NTH`'s error after
    `form` has run. Not yet: `MULTIPLE-VALUE-SETQ`.
- **Characters (M11):** Unicode scalar values (`Value::Char(char)`). Self-evaluating. Reader syntax
  `#\` (the first scalar after `#\` always belongs to the token). One-character tokens preserve case;
  longer names are case-insensitive. Required names `Space` and `Newline`; semi-standard `Tab`,
  `Page`, `Return`, `Backspace`, `Rubout`, `Linefeed` (`Linefeed` = `Newline` = U+000A). **Rustlisp
  reader extensions:** `Null` (U+0000) and `U+XXXX` (1–6 hex digits, Unicode scalars only). Printer:
  graphic characters including Space as `#\` plus the character; `Newline` and the named controls by
  name; `Null` as `#\Null` (a rustlisp extension); other unnamed characters for which Rust
  `char::is_control()` is true as `#\U+XXXX` (at least four uppercase hex digits, a rustlisp
  extension). Remaining non-control Unicode scalars print as `#\` followed by the scalar.
  `(eq #\A #\A)` is `T` because characters are immediate (rustlisp permission, not a
  portability guarantee). Compare with `CHAR=`.
- **Strings (M11):** simple heap objects, a private vector of characters, indexed by character, not
  interned, never `NIL`. Self-evaluating. Reader syntax `"..."` (`"` is terminating; `\` includes the
  next scalar literally, so `\n` is the letter `n`; an actual newline is data). Printer surrounds with
  quotes and escapes `"` and `\`; newline is emitted as itself, not as `\n`. `(eq "a" "a")` is `NIL`
  for separately read literals; `(let ((s "a")) (eq s s))` is `T`. Compare with `STRING=`. There is
  no string-mutation API yet.
- **Vectors (M40):** `HeapObject::Vector`, a one-dimensional array of any objects with an optional fill pointer and an
  adjustable flag. Reader and printer syntax `#(a b c)`, self-evaluating. `VECTOR`, `MAKE-ARRAY` (rank 1 only), `AREF`, `SVREF`,
  `VECTORP`, `ARRAYP`, `SIMPLE-VECTOR-P`, `FILL-POINTER`, `VECTOR-PUSH`, `VECTOR-PUSH-EXTEND`, `VECTOR-POP`, `ADJUST-ARRAY` and
  the `ARRAY-` queries; at most 16 Mi elements. Strings are separate objects (`VECTORP` is true for them, `SVREF` refuses
  them). See [vectors, hash tables and the sequence library](data-structures.md).
- **Hash tables (M40):** `HeapObject::HashTable` with the tests `EQ`, `EQL`, `EQUAL` and `EQUALP`; `MAKE-HASH-TABLE`, `GETHASH`
  (two values), `REMHASH`, `CLRHASH`, `MAPHASH`, `HASH-TABLE-P`, `HASH-TABLE-COUNT`, `HASH-TABLE-TEST`, `SXHASH`, `EQUALP`.
  Insertion-ordered; printed as `#<HASH-TABLE :TEST EQL :COUNT n>`.
- `NIL`: one canonical object that is the empty list, false and a symbol. `nil`, `NIL` and `()`
  all read as it. Self-evaluating. It cannot be called (`(nil)` is an undefined-function error).
- `T`: the canonical self-evaluating symbol.
- **Self-evaluating objects.** Integers, characters, `NIL`, `T`, keyword symbols, package objects, string objects, vectors, hash tables, and function
  objects evaluate to themselves. Function objects cannot appear in source text, but a macro
  expansion or a host can put one in code. Internal runtime objects (environment bindings) are not
  Lisp objects and remain a type error if a host evaluates one; a stale handle is `StaleHandle`, never a self-evaluating object.
  Arbitrary non-string heap objects that are not functions do not self-evaluate.
- Symbols (ADR 0013, ADR 0035). `SymbolId` is a `u32` index. A symbol is not a heap object.
  `CL` (nickname `COMMON-LISP`), `KEYWORD` and `CL-USER` (nickname `COMMON-LISP-USER`) exist from
  the start. `CL-USER` uses `CL`. `*PACKAGE*` starts as `CL-USER`. The reader upcases an unqualified
  name and interns it in the current package, inheriting external symbols of packages that package
  uses. `CL:CAR` is the external symbol `CAR` in `CL`, the same symbol an unqualified `CAR` reads as
  while `*PACKAGE*` is `CL-USER`. A single colon does not see inherited symbols, so `CL-USER:CAR` is
  a reader error. `CL-USER::CAR` is that same `CL:CAR`. `:FOO`, `KEYWORD:FOO` and `KEYWORD::FOO` are
  one keyword; the colon is not part of the print name. A missing package, or `CL:NO-SUCH`, is a
  reader error and interns nothing. `FOO:123` and `123:BAR` are qualified names of the same kind.
  Bare `:` and the other bad markers (`:123`, `::bar`, `foo:`, `:a:b`) stay reader errors.
  A package is an immediate object, not a heap object. It prints as `#<PACKAGE NAME>`.
  `FIND-PACKAGE`, `PACKAGEP`, `PACKAGE-NAME`, `SYMBOL-PACKAGE`, `MAKE-PACKAGE`, `INTERN`,
  `FIND-SYMBOL`, `EXPORT`, `USE-PACKAGE` and `SHADOW` are builtins. `IN-PACKAGE` is a Layer 0 macro.
  `FIND-PACKAGE` and `MAKE-PACKAGE` are case-sensitive (`"cl"` does not find `CL`).
  **`DEFPACKAGE` (M50)** is a Layer 0 macro. It is absent on the bare kernel and can be
  redefined. The name and the option arguments are string designators and are not evaluated.
  The options are `:USE`, `:EXPORT`, `:SHADOW`, `:NICKNAMES`, `:IMPORT-FROM`, `:SHADOWING-IMPORT-FROM`
  and `:INTERN` (M66); `:DOCUMENTATION` and `:SIZE` are accepted and ignored. Several clauses of one
  kind are joined. An omitted
  `:USE` uses `CL`. An empty `(:USE)` uses nothing extra. Processing order: `:SHADOW`,
  `:SHADOWING-IMPORT-FROM`, `:USE`, `:IMPORT-FROM`, `:INTERN`, `:EXPORT`. Defining the
  same name again finds the package, uses again, exports again and shadows again, and does not unuse,
  unexport or unshadow. A bad option is an error while expanding, before a package is created.
  **Package inspection and editing (M66, ADR 0061):** `LIST-ALL-PACKAGES`, `PACKAGE-NICKNAMES`,
  `PACKAGE-USE-LIST`, `PACKAGE-USED-BY-LIST` and `PACKAGE-SHADOWING-SYMBOLS` return fresh lists (symbol
  or package creation order, not hash order). `IMPORT` makes a symbol present and refuses a different
  symbol of the same name, present or inherited; an uninterned symbol takes the package as its home.
  `SHADOWING-IMPORT` displaces a different present symbol (which loses this home) and records the
  name as shadowing. `UNEXPORT` makes an external symbol internal, `UNUSE-PACKAGE` stops inheriting,
  `RENAME-PACKAGE` replaces the name and nicknames of a user package (`CL`, `KEYWORD` and `CL-USER`
  are refused). `MAKE-PACKAGE` takes `:USE`, `:NICKNAMES` and `:SIZE` (checked and ignored); a
  failing `:USE` leaves no package. A name or nickname already taken is an error before anything
  changes. `KEYWORD` refuses `IMPORT` and `UNEXPORT`. A list argument is processed in order and is
  not atomic. Library: `DO-SYMBOLS`, `DO-EXTERNAL-SYMBOLS`, `DO-ALL-SYMBOLS` (a snapshot, so the body
  may intern), `FIND-ALL-SYMBOLS`, `APROPOS`, `APROPOS-LIST`. Still absent: `UNINTERN`,
  `DELETE-PACKAGE`, `WITH-PACKAGE-ITERATOR`, package conditions.
  **`SHADOW` (M51)** takes one string designator or a list of them, and an optional package. `NIL`
  names `"NIL"`. A name that is already present keeps that symbol. Otherwise a new internal symbol
  is created, or an external one in `KEYWORD`. That name then wins over a different inherited symbol
  in `USE-PACKAGE` and `EXPORT`. A present symbol that has not been shadowed still conflicts.
  `:NICKNAMES`, `:IMPORT-FROM`, `:SHADOWING-IMPORT-FROM`, `DELETE-PACKAGE`, `UNEXPORT` and package
  locks are absent.
  **Uninterned symbols (M43):** `MAKE-SYMBOL` takes one string and returns a fresh symbol with that
  exact print name (no case folding), not `eq` to any interned symbol. `GENSYM` with no argument or
  a string prefix builds `prefix` + the decimal value of the special `*GENSYM-COUNTER*` (initial `0`,
  prefix `"G"` when omitted) and then adds one to the counter. `(gensym n)` for a non-negative
  integer uses the prefix `"G"` and `n`, and leaves the counter alone. `NIL` is not a default. A
  counter that is not a non-negative integer, or an increment past the exact-number bit limit, is an error and
  creates no symbol. `#:foo` reads a new uninterned symbol named `FOO` on every occurrence, so
  `(eq '#:foo '#:foo)` is `NIL`; `#:123` is a symbol named `123`. Readable print uses `#:` and
  `PRINC` does not. An uninterned symbol is an ordinary variable, not a constant, even when its
  print name is `NIL`, `T` or a keyword's name. `SYMBOL-PACKAGE` of an uninterned symbol is `NIL`.
  Symbol escaping is absent.
- Cons cells, dotted-pair and list syntax; `;` comments.
- `QUOTE`, the first special operator: `(quote x)` returns `x` unevaluated and takes exactly one
  argument. `'x` is read as `(QUOTE x)`; `''a` is `(QUOTE (QUOTE A))`. Quoted lists are ordinary heap
  data and `(quote x)` returns the literal object itself, not a copy.
- **`DEFUN` (M6A):** `(defun name (required-params...) body...)` defines `name` in the global function namespace
  and returns the symbol `NAME`. `DEFUN` is an ANSI **macro**; rustlisp implements it as a native *derived form*
  (not a special operator, and not a function: `#'defun` is an error), even though user macros (`DEFMACRO`,
  `MACROLET`) exist. The function is the same kind of closure as `(function (lambda ...))`: it captures the
  lexical environment where the `DEFUN` form is evaluated (`(let ((x 10)) (defun get-x () x))` then `(get-x)`
  is 10, with `x` shared by identity), the body is an implicit `PROGN` (an empty body returns `NIL`), and
  calls by name resolve in the global function table at call time, so recursion and mutual recursion work
  and a redefinition is seen by every call made by name, including calls made inside an older closure that
  was saved earlier (`(setq old #'foo)`, redefine `foo`, `(funcall old)` runs the old body, but its own
  by-name calls reach the new `foo`). Variables and functions stay separate: `(setq foo 99) (defun foo (x)
  ...)` leaves `foo` = 99. A failing `DEFUN` (bad name, lambda list, unsupported syntax) changes nothing,
  including an existing definition.
  **Implicit named block (M7A2):** the stored body is wrapped in `(block name ...)`, so `(return-from name
  ...)` leaves that function. Anonymous lambdas are not wrapped.
  Since M70 the name may be `(setf name)` (ADR 0067, below). *Not supported:* declaration identifiers other than `SPECIAL` and the advisory ones (M60: `IGNORE`, `IGNORABLE`, `INLINE`, `NOTINLINE`, `TYPE`, `FTYPE`, `OPTIMIZE`, `DYNAMIC-EXTENT` are checked for shape and ignored, and since M67 a type specifier used as the identifier, `(fixnum x)`, as an abbreviated `TYPE`; `DECLARATION` is `NotImplemented`), and the
  lambda-list keywords other than `&optional`, `&rest`, `&key`, `&allow-other-keys` and `&aux`.
  **Documentation strings (M11/M13B):** a string in a definition or lambda body that is followed by
  another form is a documentation string (not evaluated; stored since M66 for `DEFUN`/`DEFMACRO`). A string that is the only or last
  body form is executable. Zero or more `(declare ...)` forms and at most one documentation string may
  appear in the header, in either order. A second documentation string in documentation position is
  rustlisp `InvalidSyntax`. Applied to `DEFUN`, `DEFMACRO`, local `FLET`/`LABELS`/`MACROLET`
  definitions, and anonymous lambda bodies. Not applied to `PROGN`, `LET`, `BLOCK`, or the overall
  body of `FLET`/`LABELS`/`MACROLET`. **`DOCUMENTATION` (M66, ADR 0061):** `DEFUN` and `DEFMACRO` store
  a function string, `DEFVAR`/`DEFPARAMETER` a variable string, `DEFSTRUCT` and `DEFINE-CONDITION`
  (`:documentation`) a type string. `(DOCUMENTATION name type)` accepts `FUNCTION`, `VARIABLE`, `TYPE`,
  `STRUCTURE` and `SETF` and returns the string or `NIL`; `(SETF (DOCUMENTATION ...))` sets it. A
  `DEFUN`/`DEFMACRO` without a string clears the old one. Local and anonymous functions keep nothing.
  `DESCRIBE` prints a symbol's package, value, function kind and lambda list (a special operator's
  syntax), and documentation. **Argument lists:** `(RUSTLISP-FUNCTION-INFO name)` is `NIL` or
  `(kind detail)`; for a function or macro written in Lisp `detail` is its lambda list (a macro's
  with `&WHOLE` put back), for a built-in the text of its lambda list, naming exactly the
  arguments and keywords RustLisp accepts, and for a special operator its syntax as text; `NIL`
  and `T` have none. Built-ins have no documentation strings. `scripts/generate_symbols.py`
  writes the same data for every external `CL` name to `rustlisp-symbols.json`, which the binary
  packages include for editors.
  *Protected names:* `DEFUN` refuses (`ProtectedFunctionName`) to define builtin function names, special-operator
  names (including the implemented `BLOCK`, `RETURN-FROM`, `CATCH`, `THROW`, `UNWIND-PROTECT`, `FLET`,
  `LABELS`, `MACROLET`, `MULTIPLE-VALUE-CALL`, `MULTIPLE-VALUE-PROG1`), `DEFUN` itself, `DEFMACRO`, `DEFVAR`, `DEFPARAMETER`, `MULTIPLE-VALUE-BIND`, `LOOP`, `NIL`/`T`, and the reserved standard operator names
  rustlisp does not implement yet (`DECLARE`; `LAMBDA` was reserved until M31 and is now a Layer 0 macro). This is a
  rustlisp restriction on a fixed set of symbol identities (ADR 0035), not an ANSI requirement and not
  membership of the whole `CL` package. Layer 0 names stay redefinable. An unqualified protected name
  is the `CL` symbol, so it is still refused. A distinct symbol of the same print name is not. User
  function names can be freely defined and redefined.
- **`BLOCK` / `RETURN-FROM` (M7A1):** `(block name body...)` (special operator) establishes an exit named `name`
  (any symbol, `NIL` included; not evaluated) around its body, an implicit `PROGN`; `(return-from name [result])`
  (special operator) leaves the lexically innermost block of that name, which becomes the block's value (`NIL` if
  `result` is omitted, which is one `NIL`; the result form is evaluated once as a complete packet).
  The name is resolved **lexically**: an unrelated function merely called from inside a block cannot return from
  it. The exit has **dynamic extent**: a closure created inside the block captures the lexical binding and may
  `return-from` while the block is still executing (`(block here (let ((f #'(lambda () (return-from here 42))))
  (funcall f) 99))` is 42, the rest never runs), but if it is called after the block returned (an escaped closure)
  the exit no longer exists and a **control error** is signalled; nothing is jumped into. `(return-from foo ...)`
  with no lexically visible `foo` block is an **unknown-block** error, detected *before* the result form is
  evaluated; an expired exit is detected *after* it (deliberate rustlisp behaviour). Same-name nesting uses the
  innermost binding (`(block foo (block foo (return-from foo 10)) 20)` is 20). A transfer to an outer block passes
  over the inner blocks, `LET`, calls and `FUNCALL`. **Implicit function blocks (M7A2):** the body of a function created by `DEFUN`, or by `FLET`/`LABELS` (a local
  function), is wrapped in an implicit `(block name ...)` named after the function, so `(defun foo (x)
  (return-from foo (+ x 1)) 999)` returns `(+ x 1)` and each call, recursive calls included, has its own fresh exit
  (in `(labels ((walk (xs) (if (null xs) (return-from walk 10) (+ 1 (walk (cdr xs)))))) (walk '(a b c)))` the base
  return leaves only the base call: 13). An explicit inner `(block foo ...)` shadows the implicit one; a
  `RETURN-FROM` to the function across inner blocks abandons them. A saved old function keeps its own implicit block
  after a redefinition. **Anonymous lambdas get no implicit block** (nothing is inferred from the variable they are
  stored in); an anonymous lambda created inside a function can return from that function's block while the call is
  running and signals a control error afterwards. **`RETURN` (M18)** is a Layer 0 macro equivalent to
  `(return-from nil value)` (`NIL` when the value is omitted).
- **`CATCH` / `THROW` (M7B):** `(catch tag-form body...)` (special operator) evaluates `tag-form` once and establishes a
  **dynamic** exit named by the resulting object around the body (an implicit `PROGN`; `(catch 'x)` is `NIL`);
  `(throw tag-form result-form)` (special operator; both operands are required, so `(throw 'x)` is an arity error)
  evaluates the tag, then the result form, then transfers the result to the **most recently established active**
  `CATCH` whose tag is `EQ` to the thrown tag. There is no lexical requirement: `(defun thrower () (throw 'x 10))`
  called inside `(catch 'x (thrower))` returns 10, and a closure remembers no catch (a saved `#'(lambda () (throw 'x 1))`
  is a control error outside any catch and throws to whichever matching catch is active when it runs, including a new
  one), the opposite of `BLOCK`. Tags may be any object: symbols and `NIL` match by identity, a heap object only matches
  itself (two distinct `(list 1)` conses never match; do not rely on `EQ` for numbers). Nested same-tag catches select
  the innermost. A `THROW` passes over and abandons the `BLOCK`s (including implicit function blocks) and `CATCH`es
  between it and its target, and a `RETURN-FROM` likewise passes over catches. With no matching catch the tag and result
  forms have already run, nothing is abandoned, and a **control error** ("throw: no matching catch") is signalled (unlike
  `RETURN-FROM` to an unknown block, which fails before its result form runs). The tag is a single primary value; the
  result is a complete packet. `RETURN` is Layer 0 (M18).
- **`UNWIND-PROTECT` (M7C):** `(unwind-protect protected-form cleanup-form...)` (special operator; exactly one protected
  form, any number of cleanups; only `(unwind-protect)` is an arity error). The cleanups run in order, in the form's
  lexical scope, whether the protected form returns normally, signals an error or begins a non-local transfer
  (`RETURN-FROM`/`THROW`/`GO`/`ERROR` signal); their values are discarded and the form returns the protected form's value. After a normal
  cleanup the original outcome resumes (the same error, the same transfer). **A cleanup that exits non-locally or
  signals an error supersedes the original outcome** and later cleanup forms are skipped: `(block done (unwind-protect
  (return-from done 1) (return-from done 2)))` is 2, as is the `CATCH`/`THROW` analogue. (An unhandled or non-adapted evaluator `LispError` in
  the protected form is treated like an abort: the cleanups run and the error resumes. An explicit `(error string)` is
  a `Signal` transfer when a handler is active, as are M21C selected runtime failures, and still runs these cleanups as a transfer.) While a transfer
  is in flight, the exits it passes over are already **abandoned**: a cleanup that `RETURN-FROM`s such a block or
  `THROW`s to such a catch signals a **control error** rather than reaching it. This is undefined in ANSI Common Lisp;
  rustlisp deterministically chooses the error. An abandoned matching `CATCH` is not skipped in favour of an older catch
  with the same tag ("throw: the matching catch has been exited"). Cleanups see the exits that were established when
  the form was entered (and not ones that existed only inside the protected form).
- **`TAGBODY` / `GO`:** `(tagbody {tag | statement}*)` and `(go tag)` are special operators.
  A tag is a symbol (including `NIL` and `T`) or an integer, and it is not evaluated. The same tag
  twice in one `TAGBODY` is a syntax error before any statement runs. An empty `TAGBODY` returns one
  `NIL`. Statements run for effect, in a flat loop: a `GO` resumes at that tag and does not add an
  evaluator frame, then the tagbody continues with the next statement. Falling off the end returns
  one `NIL`. `TAGBODY` does not establish `BLOCK NIL`, so `RETURN` works only when an outer block
  named `NIL` is visible (`DO` and `PROG` provide one). Tags are lexical, and an inner tag shadows
  an outer tag of the same identity. `(go missing)` with no visible tag is an unknown-go error,
  detected when the form is evaluated; `HANDLER-CASE` does not catch it. A closure created inside
  the tagbody can `GO` while the tagbody is still running. After the tagbody has returned, that
  `GO` is a control error ("go: the tagbody has been exited"). A `GO` whose argument is not a
  symbol or an integer, including a list, is a syntax error and the argument is not evaluated.
  `(go)` and `(go a b)` are arity errors. `GO` across `UNWIND-PROTECT` runs the cleanups, then
  resumes the tagbody. **`DO` / `DO*` / `PROG` / `PROG*` (Layer 0):** absent on the bare kernel.
  `DO` is `(block nil (let inits declares (tagbody #:start (if end-test (return-from nil result))
  . statements steps (go #:start))))`. The end clause is required and must be a list. No result
  forms returns `NIL`. Result forms are a `PROGN`, so a complete packet is preserved:
  `(multiple-value-list (do ((i 1)) (t (values i 2))))` is `(1 2)`. A binding is a symbol, `(var)`,
  `(var init)` or `(var init step)`. `DO` evaluates every step into a fresh temporary and then
  assigns, in source order, so the steps see the old values.
  `(do ((a 1 b) (b 2 a)) ((= a 2) (list a b)))` is `(2 1)`. `DO*` uses `LET*` and assigns each step
  before the next, so the same bindings end as `(2 2)`. `PROG` is `(block nil (let vars declares
  (tagbody . statements)))` and `PROG*` uses `LET*`. Leading `(declare ...)` forms are spliced onto
  that `LET`. `DOLIST` and `DOTIMES` are unchanged. Extended `LOOP` is not this facility.
- **`ERROR` / `HANDLER-CASE` / `HANDLER-BIND` (M21B–M21D).** `(error string)` is an ordinary protected function of exactly one
  argument, which must be a Lisp string. It signals a Lisp condition that `HANDLER-CASE` can catch.
  `(error)`, `(error "a" "b")`, and `(error 42)` retain their arity/`Type` host errors
  without a handler; under M21C an active ERROR clause can catch them. Condition
  objects, format-control plus arguments, `CERROR`, and
  `(error condition-type …)` are not supported.
  `(handler-case protected-form (error (var) form*)*)` is a protected special operator (ANSI `HANDLER-CASE`
  is a macro). `var` is optional (`(error () …)` binds nothing). The binding uses the same establishment
  path as a `LET` variable: a globally special name (`DEFVAR` / `DEFPARAMETER`) has dynamic extent for
  the handler body and is restored when the handler finishes. `HANDLER-CASE` does not process a
  declaration header. A leading `(declare (special …))` in a clause body is the executable operator
  `DECLARE`, which remains `NotImplemented` (`"the operator DECLARE"`). The handler runs **after**
  the protected dynamic extent has unwound: dynamic
  specials restored, `UNWIND-PROTECT` cleanups already run, the handler clause itself inactive. Completed
  side effects are not rolled back. Zero, one, or multiple handler values are preserved; a normal
  protected completion is transparent, including multiple values. Several `ERROR` clauses are legal; the
  first handles. Other condition types are `NotImplemented`. Nested handlers select the innermost active
  match; a handler that signals is not caught by its own clause. An unhandled `(error "boom")` is the
  host error `LispError::SimpleError` whose display contains `boom`; the same `Interp` remains usable.
  M21C selects `Type`, `ArgCount`, `ClosureArgCount`, `ClosureArgCountRange`,
  `ClosureArgCountAtLeast`, `UnboundVariable`, `UndefinedFunction`, `Arithmetic`,
  `ConstantVariable`, and `ProtectedFunctionName` as ERROR conditions when an active handler
  exists. Signalling occurs at the error origin before unwind. Without a handler, the original
  host LispError variant, fields, and Display remain unchanged (e.g. `(car 5)` returns Type).
  Host I/O, reader/EOF, resource guards, GC/handle/binding invariants, and panics stay outside
  the condition system. `InvalidSyntax`, `UnknownBlock`, `ControlError`, and `NotImplemented`
  remain uncaught in this milestone. Since M58 (ADR 0047) the object bound to `var` is a condition
  instance, a tagged vector (see "Condition types (M58)"); the clause head is a condition type, not only
  `ERROR`. **Not yet:** extended restarts (`RESTART-CASE`...), CLOS, `SIMPLE-REPL`.
- **`HANDLER-BIND` (M21D).** `(handler-bind ((error handler-form)*) body*)`
  is a protected kernel special operator (ANSI macro); the type is unevaluated and, since M58, any
  condition type specifier of ADR 0047 (a symbol, `T`, `OR`, `AND`, `NOT`). Handler forms evaluate left-to-right,
  all before activation; establishment errors search only existing handlers.
  Evaluated function designators are resolved at invocation with the ordinary
  global-symbol/function-object rules, and applied to exactly one condition.
  Successful body completion preserves every value; empty body returns one NIL.
  A normally returning handler **declines**, discarding zero/one/many returned
  values. It never recovers from ERROR by returning.
  Bind observes before unwind with origin specials and inner exits still live.
  Bind and Case search in true dynamic order: inner Case handles without outer
  Bind observation; inner Bind observes before outer Case recovery. Siblings run
  in source order, yielding FIRST SECOND CASE after two declining Bind handlers
  and an outer Case. During one handler call the entire cluster and all newer
  existing clusters are invisible to **nested signalling**; older visible
  clusters and newly established handlers work. Normal return restores temporary
  visibility and resumes the **original search** at the next sibling. A secondary
  error or other non-normal outcome terminates that search when it propagates out
  of the handler invocation. If the secondary condition is completely handled
  within that invocation and the handler returns normally, the original search
  continues to later siblings and outward handlers. Hidden and abandoned are
  distinct: transfers mark crossed Bind contours abandoned before cleanup
  signalling, and visibility restoration never resurrects them. Outside contours
  remain eligible. The order is origin → Bind → cleanup → Case; Case sees
  restored specials. THROW and RETURN-FROM from handlers use normal control flow.
  Explicit ERROR and adapted runtime errors share this dispatch. After decline,
  runtime host fallback preserves the original LispError exactly. Handler and
  condition values remain GC-rooted through nested execution. No condition hierarchy,
  SIGNAL, extended restarts or debugger are added. ADR 0018 records the HyperSpec ambiguity
  and deliberate interoperability choice for continuing siblings.
- **Backquote (M9C).** `` `template `` with `,` (comma), `,@` (comma-at) and `,.` (comma-dot) is reader syntax: the reader lowers it
  completely to an ordinary form before evaluation (built from `QUOTE`, `LIST` and `APPEND`; there is no `BACKQUOTE` operator and the
  lowered shape is not a contract), so a quoted backquote shows that ordinary form. A template with no comma is its datum, quoted
  (`` `a `` is `A`, `` `(a b c) `` is `(A B C)`, `` `() `` is `NIL`; constant structure may or may not be shared between evaluations;
  results built around commas are freshly consed). `,x` evaluates `x` and inserts that one value; `,@x` evaluates `x` and splices its
  elements; both run when the lowered form is *evaluated* (never while reading), in source order, in the lexical scope of the
  backquote. A dotted template is supported: `` `(a b . c) ``, `` `(a . ,x) `` (a comma tail is the final tail and may be any
  object). **`,@` policy (a rustlisp choice within the standard's freedom):** a splice is always **copied and validated** — its value
  must be a proper list (otherwise a `Type` error, "expected proper list", wherever the splice appears, including last), the source
  list is never shared or modified, and a final `,@x` is not turned into a shared or dotted tail the way some implementations do.
  **`,.` has exactly the `,@` result semantics:** rustlisp does not exploit Common Lisp's permission to splice destructively and has
  no `NCONC` in its lowering (the M26 Lisp function is independent). **Nesting:** the innermost backquote is expanded first and, with several commas in a row, the leftmost belongs to the
  innermost backquote; the reader tracks a numeric level (a backquote adds one, a comma subtracts one), so `` `(a `(b ,,x)) ``,
  `,',x`, `,@,x`, `,,@x`, `,@,@x` and the like work as deep as the nesting allows (macro-defining macros are the use), and a comma
  that would take the level below zero is a reader error (`` `(a ,,x) ``). **Reader errors** (`Read`): a comma, `,@` or `,.` outside
  a backquote; a splice as the whole template (`` `,@x ``) or in a dotted tail (`` `(a . ,@x) ``), which Common Lisp leaves undefined
  (rustlisp rejects them deterministically); a malformed dot; an unmatched `)`; nesting past the reader limit (256 levels,
  counting backquotes, commas and lists). Incomplete input after `` ` ``, `,`, `,@`, `,.` or inside a template is `IncompleteInput`
  (the REPL keeps reading). Strings and `#\` characters are ordinary template data; commas and
  backquotes inside a string are character data. `|`, `\` outside strings and other `#` syntax inside a template stay `NotImplemented`. `'x` and `#'x` inside a
  template are ordinary lists, so a comma inside them is active (`` `(a ',x) ``). **Terminating characters:** `'`, `` ` ``, `,` and `"`
  end a token, as in Common Lisp (`(a'b)` is `(A (QUOTE B))`, `` `(a,b) `` has a comma, `foo"bar"` is `FOO` then `"bar"`); `#` is non-terminating. A vector literal `#(...)` inside a
  template is read as a literal (nothing inside it is unquoted); `#n=` labels are not supported.
- **`DEFMACRO` and macros (M9A, M9B).** `(defmacro name macro-lambda-list body...)` (a native *derived form* like `DEFUN`: its
  operands are unevaluated, it is not a function and not a special operator) defines `name` as a global macro and returns the
  symbol `NAME`, also when it replaces an earlier definition. A global name has **one operator slot**: `DEFMACRO` over a function
  and `DEFUN` over a macro each replace the previous definition, which stops participating at once; a lexical `FLET`/`LABELS`
  function shadows a global macro of the same name, and the innermost binding of a name wins whatever its kind.
  A macro is not a function: `(function m)`, `#'m`, `(funcall 'm)` and `(apply 'm ...)` on a macro name are `UndefinedFunction`.
  Protected names (special operators, `DEFUN`, `DEFMACRO`, builtins, `NIL`/`T`, reserved standard names) cannot be macros
  (`ProtectedFunctionName`); this is the existing single-package restriction.
  **Macro lambda lists** support required parameters, `&OPTIONAL` (init forms and supplied-p), `&REST`, `&BODY` (identical to
  `&REST`), a leading `&WHOLE var` (which binds the **identical** macro-call form, `EQ` to it, not a copy), `&KEY`,
  `&ALLOW-OTHER-KEYS` and `&AUX` (M12; same binding rules as ordinary lists; operands stay unevaluated syntax objects).
  Since M68 (ADR 0066, below) they also support `&ENVIRONMENT var`, a dotted tail, and destructuring patterns
  (a list as a required parameter, as an `&OPTIONAL` or `&KEY` variable, or after `&REST`/`&BODY`). Malformed lists
  (`&WHOLE` not first or without a variable, a repeated `&REST`/`&BODY`, duplicate genuine parameter names, a non-symbol) are `InvalidSyntax`.
  Local `(declare (special ...))` in the body is supported (M13B) and is recorded on the inner user-macro
  closure; other declaration identifiers are `NotImplemented` **at definition time**. A documentation
  string in definition-body position is recognised and discarded (M11); a lone or final string is a body form.
  **Evaluation.** A macro call's operands are bound unevaluated, as source forms, to the macro parameters (this is the
  difference from a function call). `&OPTIONAL` defaults run at expansion time, see the earlier parameters as unevaluated forms and
  run only when the operand is omitted. The body runs as an implicit `PROGN` inside an implicit `(block name ...)`
  (`(return-from name expansion)` works; the lambda-list init forms are *outside* the block, as for `DEFUN`) and its last value is the
  expansion. The expander runs in the lexical environment of the `DEFMACRO` form (a macro defined inside a `LET` or `FLET` keeps
  those variables and functions after the scope is left); the expansion is then evaluated in the scope of the macro **call**,
  never in the definition scope. The `&REST`/`&BODY` list is a fresh list (a rustlisp policy: the standard neither requires fresh
  structure nor sharing with the source form), so mutating it does not change the source form. Wrong operand counts are the usual
  closure arity errors ("anonymous function expected ..."), and with `&WHOLE` they count only what the caller wrote. Errors and
  `RETURN-FROM`/`THROW`/`UNWIND-PROTECT` in the body behave as in any function; control forms in the *expansion* run later at the call
  site.
  **Failure is atomic:** an invalid definition, a protected name, a malformed declaration, or an
  unsupported declaration identifier signals before replacing any previous function or macro
  definition of the name. A valid `(declare (special ...))` is recorded on the inner closure and
  does not prevent installation.
  **Repeated expansion** is at the top level only (an expansion that is another macro form is expanded again); at most
  `MAX_MACRO_EXPANSIONS` (256) expansions run in a row, and if the result is still a macro form `MacroExpansionLimit` is signalled
  **without invoking a 257th expander** (a rustlisp safeguard, not an ANSI condition). An expansion may be `NIL`, a symbol, a
  form, or a function object (which evaluates to itself). **Implementation limit:** the synthetic whole argument takes one place in
  the internal call, so the extreme maximum operand count (`MAX_CALL_ARGUMENTS`) of an `&WHOLE` macro is one less than for an
  otherwise equivalent macro without `&WHOLE`; not an ANSI claim. A macro defined while a form is being expanded takes effect for
  later expansions; the running expander is unaffected.
  **`MACROEXPAND-1` and `MACROEXPAND` (M52)** are builtins. The form argument is evaluated.
  Each returns the resulting form and `T` or `NIL`. One step returns `T` even when the expander
  returns its input. `MACROEXPAND` repeats at the top level only and stops at the same 256 limit,
  without a further expander call. Since M69 the optional environment argument is read: omitted or `NIL`
  is the null environment (global macros only), an environment object (an expander's `&ENVIRONMENT`
  variable) its local macros and symbol macros; see ADR 0066, below. `MACRO-FUNCTION` and symbol
  macros exist since M69. **Not supported yet:** compiler macros, `*MACROEXPAND-HOOK*`.
  **Undefined (as in Common Lisp):** destructive modification of the form supplied to a macro expander, or of any other code that
  is currently being evaluated (for example a list a macro returned and also kept). It is not a portable or guaranteed technique and
  rustlisp specifies no result for it: which code then runs is an implementation detail. The evaluator is GC-safe in that case
  (it never uses a collected object, so there is no `StaleHandle`, and every GC policy behaves alike), but that is a safety
  property, not a supported semantic. See "Operators and macro expansion (M9A)", "`DEFMACRO` (M9B)" and "Rooting invariant for
  evaluator frames" in `docs/architecture.md`.
- **Definitions inside another form (ADR 0064 items 16, 17).** The compiled machine (the default evaluator since ADR 0064
  stage 8; see [Evaluation by the compiled machine](#evaluation-by-the-compiled-machine-adr-0064)) compiles the whole
  top-level form first, as SBCL does, and a `DEFMACRO`, `DEFVAR`,
  `DEFPARAMETER`, `DEFSETF` or `DEFINE-SETF-EXPANDER` inside it takes effect when it runs: a use of the new macro later in that
  form is a call of a function (`UNDEFINED-FUNCTION`), a binding of the new variable compiled earlier stays lexical, and a
  `SETF` of the new place fails. A use of a macro inside its own `DEFMACRO` body expands with the older definition, or with none
  is a call of a function. ANSI gives these definitions compile-time effects only as top-level
  forms, so this behaviour conforms.
- **`MACROLET` (M9D):** `(macrolet ((name lambda-list body...)...) body...)`, a special operator, establishes local macros in
  the lexical function namespace (`Macro`-kind `FunBinding`s). It is `FLET`-shaped: expander functions capture the **outer**
  `Scope`; the body sees the new bindings. Sibling expanders do not see each other (`(macrolet ((a () 1) (b () (a))) (b))` is
  `UndefinedFunction` for `A`); a sibling name in a *returned* form is expanded at the call site, where both bindings exist
  (`(macrolet ((a () 1) (b () (list 'a))) (b))` is `1`). Definition order does not create one-way visibility. An inner
  `MACROLET` shadows an outer one in its body; an expander of the inner form captures the outer scope and so may call an outer
  local macro. `FUNCTION` / `#'` on a local macro is `UndefinedFunction`; a symbol used as a function designator (`funcall`/`apply`)
  is the global function only. A `DEFMACRO` or `DEFUN` in the body replaces the global slot only; later body forms still expand
  the local macro. A closure created in the body retains the local macros. The global operator table is not touched. Duplicate
  names and a non-symbol name (including `(setf m)`) are `InvalidSyntax`; protected names are `ProtectedFunctionName`.
  Local `(declare (special ...))` is supported in each expander body and as free `SPECIAL` names on the `MACROLET`
  outer body (applied after expanders capture the outer variable contour); other declaration identifiers remain
  `NotImplemented`. Macro lambda lists, the implicit named `BLOCK`, atomic
  validation (nothing runs if a later definition is bad), and the two-closure expander are those of `DEFMACRO`.
  **rustlisp policy (not an ANSI guarantee):** Common Lisp leaves undefined a local macro definition that refers to a lexical
  variable or function binding visible around the `MACROLET`. The compiled machine (the default, ADR 0064 item 18) makes the
  expander while compiling, where it sees only the outer local macros and the global environment: such a reference reads the
  global variable or function, and a `RETURN-FROM` or `GO` to a block or tag outside the `MACROLET` is unknown.
- **Kernel versus standard image (M10).** `Interp::new()` is the bare Rust kernel and does not define `LISTP`, `NOT`, `WHEN`,
  `UNLESS`, `AND`, `VALUES-LIST`, `MULTIPLE-VALUE-LIST` or the 28 composed `C[AD]{2,4}R` functions. `Interp::standard()` evaluates Layer 0 (`lisp/layers/`) through the ordinary reader and
  evaluator. The rustlisp executable uses the standard image. Tests and hosts that construct `Interp::new()` stay on the
  kernel. See `docs/architecture.md` ("Kernel and Lisp layer") and ADR 0011.
- **`NOT` (M10):** ordinary function `(not object)`, defined in Lisp: `T` if `object` is `NIL`, otherwise `NIL`.
- **`WHEN` (M10):** macro `(when test body...)`, defined in Lisp, expands to `(if test (progn body...))`. An empty body
  yields `NIL`. The test is evaluated once. `(when)` (missing `test`) is a closure arity error
  (`ClosureArgCountAtLeast`), the same class of error as other user macros, not a special-operator `ArgCount`.
- **`UNLESS` (M10):** macro `(unless test body...)`, defined in Lisp, expands to `(if test nil (progn body...))`.
- **`AND` (M10):** macro `(and forms...)`, defined in Lisp. No forms yields `T`; one form is that form (evaluated);
  more than one is `(if first (and rest...))`, so later forms are not evaluated once a form is `NIL`. Nested
  expansions consume evaluator depth per remaining clause.
  **Redefinition (rustlisp policy in this milestone, not an ANSI claim):** `LISTP`, `NOT`, `WHEN`, `UNLESS`, `AND`,
  `VALUES-LIST`, `MULTIPLE-VALUE-LIST` and the composed `C[AD]{2,4}R` functions occupy ordinary operator slots. A user `DEFUN`/`DEFMACRO` may replace
  them in that interpreter; a second `Interp::standard()` has the original prelude; `MACROLET`/`FLET` may
  shadow them lexically. They are not protected names.
- **`FLET` (M6B1):** `(flet ((name lambda-list body...)...) body...)`, a special operator, establishes local
  functions in the lexical **function** namespace (separate from variables: `(let ((foo 99)) (flet ((foo (x) (+ x 1)))
  (list foo (foo 4))))` is `(99 5)`). **FLET definition bodies capture the OUTER lexical function environment;
  the FLET body sees the new one.** So the definitions are simultaneous and do not see each other or themselves
  by name: in `(flet ((foo () (foo))) (foo))` the inner call reaches the *outer* or global `foo` (or is
  `UndefinedFunction`), and `(flet ((a () (b)) (b () 2)) (a))` never sees the local `b`. (`LABELS` is the
  form where they do.) The body is an implicit `PROGN`; nothing in a definition runs when the
  form is entered. Resolution order for an operator-position name and for `(function name)` / `#'name` is: lexical
  function, then global function, else `UndefinedFunction`; local functions shadow ordinary user functions and
  nested `FLET`s shadow outer ones, and the global table is never changed. **`#'foo` inside FLET is a lexical
  lookup; `'foo` used as a function designator, as in `(funcall 'foo)`, is always a global lookup**
  (`(flet ((foo () 1)) (list (foo) (funcall #'foo) (funcall 'foo)))` with a global `foo` returning 100 is `(1 1 100)`).
  Local closures are the ordinary closures: they capture the variables where the `FLET` is evaluated, survive
  after it returns (escaping), and a `DEFUN` evaluated inside a `FLET` keeps the lexical functions it refers to.
  Local names may not be protected core names (builtins, special operators, derived forms, `NIL`/`T`, reserved
  standard names): `ProtectedFunctionName`. This is a rustlisp restriction on those symbol identities
  (ADR 0035). `CL:CAR` and an unqualified `CAR` are that protected symbol. A symbol with the same print
  name in another package is not. Duplicate local names are `InvalidSyntax` (a rustlisp restriction). Generalised names
  `(setf f)` and lambda-list keywords other than `&optional`, `&rest`, `&key`, `&allow-other-keys` and `&aux` are
  not supported (`NotImplemented`, before anything runs). Local `(declare (special ...))` is supported in each
  definition body and as free `SPECIAL` names on the `FLET` outer body (applied after local closures capture the
  original variable contour). Other declaration identifiers remain `NotImplemented`.
- **`LABELS` (M6B2):** `(labels ((name lambda-list body...)...) body...)`, a special operator, is `FLET` with a
  different scope for the local names. **FLET closures capture the OUTER lexical function environment; LABELS
  closures capture the COMPLETED local function environment.** So in a `LABELS` every local function is visible in
  the body *and inside every definition*: self-recursion and mutual recursion work
  (`(labels ((len (xs) (if (null xs) 0 (+ 1 (len (cdr xs)))))) (len '(a b c)))` is 3). With a global `b` returning 100,
  `(flet ((a () (b)) (b () 2)) (a))` is `100` but `(labels ((a () (b)) (b () 2)) (a))` is `2`. Everything else is as
  for `FLET`: the function namespace is separate from variables; resolution is lexical first, then global;
  `#'foo` is a lexical lookup while a quoted symbol designator as in `(funcall 'foo)` is global; closures capture
  the variables where the form is evaluated, may escape (an escaped recursive closure keeps working and keeps its
  mutually recursive siblings alive), and a `DEFUN` inside a `LABELS` keeps the local functions it refers to; the
  body is an implicit `PROGN`; no local function body runs when the form is entered; names may not be protected
  core names (a rustlisp restriction on those symbol identities, ADR 0035) and duplicates are rejected (a rustlisp
  restriction); `(setf f)` names (which `DEFUN` accepts since M70) and lambda-list keywords other than `&optional`, `&rest`, `&key`, `&allow-other-keys` and `&aux` are not supported.
  Local `(declare (special ...))` is supported in each definition body and as free `SPECIAL` names on the `LABELS` outer
  body (applied after local closures capture the completed function environment); other declaration identifiers remain
  `NotImplemented`. Local function bodies receive the same implicit named `BLOCK` as `DEFUN` (M7A2).
- **`#'` (M5C):** the reader reads `#'form` as the ordinary list `(FUNCTION form)`, exactly as `'x` reads as
  `(QUOTE x)`: `#'list` is `(function list)` and `#'(lambda (x) (+ x 1))` is `(function (lambda (x) (+ x 1)))`.
  It is pure reader sugar within the currently supported `FUNCTION` subset (a global function name or a
  lambda expression), so name resolution, closures and capture are exactly those of explicit `FUNCTION`; `#'list`
  never consults the variable `list`. `'foo` is the symbol `FOO`, `#'foo` the function named `FOO`
  (`(functionp 'list)` is `NIL`, `(functionp #'list)` is `T`). A trailing `#'` or `#` is incomplete input.
  `#\` character syntax is implemented (M11), `#(` vectors (M40), and `#:` uninterned symbols (M43).
  Every other `#` dispatch (`#x`, `#|`, ...) remains an explicit "not implemented" error. Function
  objects still print as `#<FUNCTION LIST>`, not as `#'LIST`.
- **Truth:** `NIL` is false; every other object is true. `0` is true, `T` is true, a cons is true
  even if it holds `NIL`, and `'nil`, `'()` and `(list)` are false.
- `IF`, special operator: `(if test then)` and `(if test then else)`. `test` is evaluated first;
  if non-`NIL`, `then` is evaluated and returned and `else` is **not** evaluated; otherwise `else`
  is evaluated and returned, or `NIL` if absent. The unselected branch is never evaluated or even
  inspected, so `(if t 1 (car 10))` is `1` and `(if nil (car 10) 2)` is `2`. Fewer than two or more
  than three arguments is an arity error; a dotted form such as `(if t 1 . 2)` is a syntax error.
- `PROGN`, special operator: evaluates its forms left to right and returns the value of the last
  one; `(progn)` is `NIL`. Strictly sequential: each form completes, with its side effects, before
  the next starts, and an error stops the rest. A dotted body is a syntax error, reported before any
  form runs. (`IF` and `PROGN` are operators, not functions: `if` and `progn` as variables are
  unbound, and they are ordinary data when quoted.)
- **Variables.** `NIL` and `T` are constants. Any other symbol evaluates to its innermost lexical
  binding; if there is none, to its global value; if there is none either, evaluation fails with an
  unbound-variable error. A variable bound to `NIL` is bound (`(let ((z nil)) z)` is `NIL`), which is
  different from unbound. Naming or quoting a symbol does not give it a value. Global values come only
  from `SETQ` and `SETF` of a variable. Variables are a separate namespace from functions: `(let ((car 5)) (car '(1)))`
  calls the function `CAR`, a function name used as a variable is unbound, and a variable is not a
  function (`(let ((foo 1)) (foo))` is an undefined-function error). The special-operator names are
  only special in operator position (`(let ((if 3)) (if if 'yes 'no))` is `YES`).
- `SETQ`, special operator: `(setq {var form}*)`. Variables are not evaluated. Pairs are processed
  in order; each form is evaluated in the current environment *after* the earlier assignments
  (`(setq x 1 y (+ x 1))` makes `y` 2; `PSETQ` reads every value first). Assignment writes the same location a
  reference in that scope would read: a visible Declare mark updates the innermost dynamic binding or else
  the global cell; otherwise a lexical binding is updated in place; otherwise an active dynamic
  binding; otherwise the global value is set, creating it if needed. `(setq x 10)` at top level makes
  `x` evaluate to `10`. The result is the last value assigned, `NIL`
  for `(setq)`. A lexical binding shadows the global, and assigning the shadowing variable leaves the
  global alone (`(setq x 10)`, then `(let ((x 20)) (setq x 30) x)` is `30` and `x` is still `10`);
  assigning a name with no lexical binding inside a `LET` sets the global, which outlives the `LET`.
  `SETQ` never proclaims a symbol special.
  `SETQ` changes which object a variable refers to and never mutates the old object
  (`(let ((x (list 1))) (let ((y x)) (setq x (list 2)) y))` is `(1)`, whereas
  `(rplaca x 2)` in the same place gives `(2)`). It does not affect function names:
  `(setq list 42)` leaves `(list 1 2)` working and makes `list` evaluate to `42`.
  Errors: assigning `NIL` or `T` is a constant-variable error and no global cell is created; an odd
  number of arguments is an arity error; a non-symbol variable or a dotted/improper form is a syntax
  error. The whole form is checked before any assignment runs, so such errors assign nothing. If a value
  form signals an error partway through, the assignments made before it remain.
- **`PSETQ` (M53):** Layer 0 macro, absent on the bare kernel, redefinable.
  `(psetq {var form}*)` reads every value form left to right, then assigns left
  to right, and returns `NIL`. `(psetq a b b a)` exchanges. A repeated name is
  assigned again, so `(let ((a 1)) (psetq a 2 a a) a)` is `1` and
  `(let ((a 0)) (psetq a 1 a 2) a)` is `2`. Each value contributes its primary
  value. `SETQ` does the writes, including writes to specials. `NIL`, `T`, a
  keyword, a non-symbol, an odd argument count, or a circular list is an error
  while expanding, and nothing is read or assigned. A dotted call is a syntax
  error before the expander. A compound place is that same expansion error;
  `PSETF` (Layer 0, the library module) assigns places.
- **`GET-SETF-EXPANSION` (M47):** a kernel builtin,
  `(get-setf-expansion place &optional environment)`. It returns five values:
  temporary variables, value forms, store variables (one), the store form, and
  the access form. The temporaries and the store variable are fresh uninterned
  symbols. The environment argument is accepted and ignored; there is no
  environment object. A call made while a macro expander is running analyzes
  the place in that expander's call-site scope, so `SETF` of a `MACROLET` place
  works. A direct call uses the global environment and does not see `MACROLET`.
  The store form is `SETQ`, one of the protected `RUSTLISP-SET-*` builtins, or
  the form produced by a `DEFSETF` or `DEFINE-SETF-EXPANDER` registration
  (below). It returns the stored value.
- **`SETF` (M16, Layer 0 since M47):** ANSI `SETF` is a **macro**, and that is
  how rustlisp implements it. It is absent on the bare kernel (`UndefinedFunction`)
  and is an ordinary redefinable prelude macro. `#'setf` is `UndefinedFunction`.
  Syntax: `(setf {place new-value-form}*)`. The argument list must be a proper
  even-length list before any pair is expanded; an odd count is `ArgCount` and
  assigns nothing; a dotted list is `InvalidSyntax`. `(setf)` is one `NIL`.
  Pairs run left to right. A later pair is expanded only after the earlier
  store, so a later constant-variable or type error leaves the earlier store
  and does not evaluate the later new-value form. Each new-value form is
  evaluated to a complete multiple-value packet: zero values store `NIL`; extra
  values are discarded; the pair returns exactly one value, the stored primary,
  which is also the result of the whole `SETF` for the last pair.
  `(multiple-value-list (setf x (values 1 2)))` is `(1)`.
  `(multiple-value-list (setf x (values 1 2) y (values 3 4)))` is `(3)`.
  Supported places: a non-constant symbol (same assignment authority as `SETQ`:
  lexical, global, dynamic special, proclaimed special, locally declared
  `SPECIAL`, Shadow, closure mutation); `(car object-form)` and
  `(cdr object-form)` (exactly one object form; the result is the stored value,
  not the cons); the M40 places `AREF`, `SVREF`, `ELT`, `NTH`, `GETHASH`
  (including its default form) and `FILL-POINTER`; ordinary nesting such as
  `(setf (car (cdr form)) value)`, where the inner `CDR` is an ordinary
  evaluation of the `CAR` place's object form, not a nested SETF place; and a
  macro whose expansion is a supported place (`DEFMACRO` or `MACROLET`, bounded
  by `MAX_MACRO_EXPANSIONS`). `NIL`, `T` and keywords are constant-variable
  errors during analysis of that pair, before its new-value form. `CAR`/`CDR`
  type errors (`expected: "cons"`) occur at store time, after the new-value
  form. A read of `CAR`/`CDR` expects a list. An ordinary function with no
  registered expansion (`LIST`, `GETF`, `SECOND`, `VALUES`, …) is rejected
  during analysis with `InvalidSyntax` (`SETF: no setf expansion for NAME`) and
  does not evaluate place subforms or the new-value form. This is a current
  subset restriction, not a reproduction of the ANSI `(SETF reader)` function:
  rustlisp cannot yet represent that function name. An undefined operator is
  `UndefinedFunction`. Place subforms of a failed analysis do not run. Object
  forms and new-value forms of a successful place are each evaluated once.
  Since M70 an operator with no builtin place, macro or `DEFSETF` stores
  through its `(SETF name)` function (ADR 0067, below), so the paragraph above
  about ordinary functions and undefined operators now holds only for
  builtins. `PSETF`, `SHIFTF` and `ROTATEF` are Layer 0 (library module), and
  since M69 a symbol macro is the place its expansion is. Not supported:
  `VALUES` as a place.
- **`DEFINE-SETF-EXPANDER` (M49):** a native derived form, present on the bare
  kernel and protected. `(define-setf-expander access lambda-list body*)`
  installs a closure. The closure is called with the unevaluated place
  subforms and must return five values. The lambda list is an ordinary
  lambda list. `&ENVIRONMENT var` is accepted and that variable is bound to
  `NIL`. A documentation string is accepted and ignored. The registration
  replaces a `DEFSETF` of the same name, and a later `DEFSETF` replaces it.
  Builtin places and reserved operators are rejected. The store-variable
  list must hold exactly one element.
- **`SETF` of `GETF` (M49):** `(setf (getf place indicator [default]) new)`.
  `place` is itself a place. The indicator is evaluated once, after the
  inner place's subforms and before the new value. The default form is not
  evaluated by the store. A read of the place (for example `INCF`) does
  evaluate it. The first `EQ` pair is updated in place and the surrounding
  place is not written. A missing indicator stores a new pair through the
  inner place. The result is the new property value. A stored `NIL` is
  present. A later duplicate indicator is left unchanged. The plist is an
  ordinary list. There is still no symbol plist.
- **`DEFSETF` (M48):** a native derived form, present on the bare kernel and
  protected like `DEFMACRO`. `(defsetf access updater [documentation])` names
  an updater symbol. The updater need not exist yet; a missing updater is
  `UndefinedFunction` when the place is stored, after the subforms and the
  new value have run. The updater's values are the values of that `SETF`.
  `(defsetf access lambda-list (store-var) [documentation] body*)` builds an
  anonymous expander. The lambda list is required parameters only. The store
  list is exactly one symbol, distinct from the parameters. The body is
  called with fresh uninterned symbols during `GET-SETF-EXPANSION` and its
  primary value becomes the store form. A documentation string is accepted
  and ignored. `NIL` as the second argument is the updater `NIL` (rejected,
  because `NIL` is a constant) unless the next form is a list, in which case
  it is a long form with no parameters. A builtin place (`CAR`, `CDR`,
  `AREF`, `SVREF`, `ELT`, `NTH`, `GETHASH`, `FILL-POINTER`) and a reserved
  operator are rejected. A macro of the same name is expanded first, so the
  macro hides the registration. A long form used with the wrong number of
  arguments is `InvalidSyntax` during analysis and evaluates nothing. A
  returned store form of `NIL` is `InvalidSyntax` (`DEFSETF: the expander
  returned no store form`). The expander captures no lexical environment.
- **`PUSH` (M17, Layer 0 since M47):** ANSI `PUSH` is a **macro**, and that is
  how rustlisp implements it. It is absent on the bare kernel and redefinable
  in the prelude. `#'push` is `UndefinedFunction`. Syntax: `(push item-form place)`.
  The place is analyzed while the macro expands; a constant place
  (`NIL`/`T`/keyword) is rejected there, before the item form. Then: evaluate
  the item to a primary (zero values use `NIL`; extra values are discarded);
  evaluate place subforms left to right once; read the place; allocate
  `(cons item old-value)`; store it; return exactly that cons. The item form
  runs **before** place subforms. Supported places are the `SETF` places above.
- **`POP` (M48):** a Layer 0 macro, absent on the bare kernel and redefinable.
  `#'pop` is `UndefinedFunction`. Syntax: `(pop place)`. The place is
  analyzed while the macro expands. The expansion evaluates the place
  subforms, reads the place, takes `CAR`, then stores `CDR`, and returns the
  `CAR`. A type error from `CAR` stores nothing. `(let ((x nil)) (pop x))`
  returns `NIL` and leaves `x` as `NIL`. `(pop nil)` is a constant-variable
  error. The result is exactly one value.
- **`PUSHNEW` (M48):** a Layer 0 macro, absent on the bare kernel and
  redefinable. `#'pushnew` is `UndefinedFunction`. Syntax:
  `(pushnew item-form place &key key test test-not)`. The item is evaluated
  before the place subforms. The place is read once. The keyword arguments
  are evaluated by `MEMBER`, after that read. If the item is already present
  the existing value is returned and nothing is stored. Otherwise a fresh
  cons is stored and returned. An odd keyword tail is `ArgCount` (`2 plus
  keyword pairs`) before the place is analyzed. Fewer than two arguments is
  `ArgCount` (`at least 2`).
- **`INCF` / `DECF` (M36, Layer 0 since M47):** ANSI `INCF`/`DECF` are
  **macros**, and that is how rustlisp implements them. They are absent on the
  bare kernel and redefinable in the prelude. `#'incf` is `UndefinedFunction`.
  Syntax: `(incf place [delta-form])` and the same for `DECF`. An omitted delta
  is the literal `1`. The form returns the new value (exactly one value). The
  place is analyzed while the macro expands (a constant place is rejected
  there; an unsupported place is `InvalidSyntax` `SETF: no setf expansion for
  NAME`, with no subform run). Then, in this order: place subforms left to
  right, once; the **old value is read**; the delta form is evaluated (once);
  the sum or difference is computed with the ordinary `+` or `-` builtin
  (exact arithmetic with bignum promotion); the store. A type error or resource-limit error is an adapted
  `ERROR` condition, and nothing is stored; so is any error or non-local exit
  in a place subform or the delta. Because the old value is read before the
  delta runs, `(let ((x 1)) (incf x (progn (setq x 100) 5)))` is `6` (SBCL's
  compiler may read a plain variable later and give `105`). Supported places
  are the `SETF` places above, including `NTH`, `AREF`, `SVREF`, `ELT`,
  `GETHASH` and `FILL-POINTER`, and the places of the later sections (the list
  accessors, `GETF`, setf functions). **Not supported places:** `VALUES`, and
  `NIL`/`T`/keywords.
  `(decf x)` of the most negative fixnum stores a bignum. At the base of a recursion the expansion costs 5 evaluator
  levels (measured in `tests/m36.rs`). The shipping entry points stay in deep
  mode.
- **`COND` (M17, Layer 0 since M44):** ANSI `COND` is a **macro**, and that is how rustlisp
  implements it. It is absent on the bare kernel (`UndefinedFunction`) and is an ordinary
  redefinable prelude macro. `#'cond` is `UndefinedFunction`. The expansion is one `BLOCK`
  named by a `GENSYM`, so a long clause list does not nest evaluator frames and `RETURN`
  still targets an outer `BLOCK NIL`. Evaluating the expansion pays for that `BLOCK`,
  the clause `IF` and the `RETURN-FROM` on every call, so recursion through `COND`
  (and through `OR`, which lowers to it) fits fewer levels of the 80-unit limit than
  the native form did. The shipping interpreter runs in deep mode. Clauses are validated before any test runs. An empty
  clause, a non-list clause and a dotted clause are `ERROR`s (`SimpleError`). `(cond)` is one
  `NIL`. Each test is evaluated once. A false primary, including zero values, continues. A true
  test-only clause returns exactly one value, the test's primary:
  `(multiple-value-list (cond ((values 1 2))))` is `(1)`. A true clause with a body is an
  implicit `PROGN` and propagates the last form's complete packet:
  `(multiple-value-list (cond (t (values 1 2))))` is `(1 2)`. No matching clause is one `NIL`.
  Scheme `=>` is not recognised. M27 `OR` still lowers to `COND`.
- **Simple `LOOP` (M18):** ANSI `LOOP` is a **macro** (simple and extended). rustlisp implements
  **simple LOOP only** as a protected native derived form: `(loop form*)` establishes an implicit
  `BLOCK NIL` and repeatedly evaluates the body, discarding each ordinary packet, until `RETURN` /
  `RETURN-FROM NIL` delivers a complete packet. Other transfers propagate. The iteration is a Rust
  loop: evaluator depth returns to the same level each iteration, and a nested temporary-root scope
  drops per-iteration roots. Extended clauses (`FOR`, `WITH`, `COLLECT`, `SUM`, `WHILE`, `UNTIL`, …)
  are not recognised; every body form is ordinary Lisp, including atoms. A symbol that resembles an
  extended LOOP keyword (`FOR`, `COLLECT`, …) is evaluated as an ordinary variable, not parsed as a
  clause. That silent overlap is a documented limitation of this subset, not extended LOOP. `#'loop`
  is `UndefinedFunction`. In the tree walker `MAX_EVAL_DEPTH` is unchanged and there is no
  evaluator trampoline; the compiled machine (the default) compiles the loop to a jump.
- **`RETURN` (M18):** Layer 0 `(defmacro return (&optional value) (list 'return-from nil value))`.
  Ordinary redefinable prelude slot. `(return)` is one `NIL`; `(return form)` propagates `form`'s
  packet through `RETURN-FROM NIL`.
- **Host I/O (M18).** (Since M37 the host streams are reachable as the stream objects `*STANDARD-INPUT*` / `*STANDARD-OUTPUT*`; see [Text streams (M37)](#text-streams-m37).) `Interp` owns `HostInput` (process stdin or a byte buffer)
  and `HostOutput` (process stdout or a captured buffer, plus beginning-of-line). Defaults are
  process stdin/stdout. Tests and embeddings use `set_input_text`, `capture_output` /
  `set_io_buffers`, and `take_output_string`. There is no stream `HeapObject`, no `RefCell`, no
  lifetime on `Interp`, and no persistent GC root category. The host REPL still uses `println!` /
  stderr; it does not route through the Lisp output sink.
  Stream designators for `READ-LINE` / `PRINC` / `FRESH-LINE` (M37) and every M38 stream operation: omitted or `NIL` mean the current value of
  `*STANDARD-INPUT*` / `*STANDARD-OUTPUT*`, `T` the host stream, and an open stream object of the right direction
  is itself; any other object is a `Type` error (M18 had `NotImplemented`).
- **`READ-LINE` (M18):** `(read-line &optional input-stream eof-error-p eof-value recursive-p)`
  returns two values, the line and `missing-newline-p`. Trailing LF is stripped; a CR immediately
  before that LF is stripped; a bare CR is data. A successful line excludes the terminator. The
  second value is `T` when EOF ended the line without a newline. Immediate EOF with `eof-error-p`
  true (the default) is `LispError::EndOfFile` for the host input (never `IncompleteInput`) and a catchable
  `LispError::Stream` for a file stream. With `eof-error-p` false
  the primary is `eof-value` (default `NIL`) and the secondary is `T`. `recursive-p` is accepted and
  ignored. Host I/O errors are `LispError::Io`. The blocking read fills an owned Rust `String` before
  any Lisp string is allocated.
- **`READ-FROM-STRING` (M18):** `(read-from-string string &optional eof-error-p eof-value &key start
  end preserve-whitespace)` returns the object and a **character** index (not a UTF-8 byte offset)
  into `string`: the index of the first character in the bounded range that was **not** consumed.
  `START` defaults to 0; `END` defaults to the character length; **`:END NIL` and `:START NIL` mean
  those defaults**. Bad bounds are an error. One object is read through the existing `Reader`.
  Leading whitespace and comments in the bounded range are skipped before the object in both modes.
  `preserve-whitespace` false is ordinary `READ`: a token's **one** terminating whitespace character
  is consumed; further whitespace, comments, and non-whitespace delimiters stay unread. Lists and
  strings end at `)` / `"`, so a following space is not consumed. `preserve-whitespace` true is
  `READ-PRESERVING-WHITESPACE`: that terminating whitespace is left unread. The position is never
  faked by skipping the rest of the bounded range after a successful object. If no object begins
  (whitespace/comments through the end of the range), `eof-error-p` / `eof-value` apply and the
  position is the **end of the bounded range**, not `START`. An incomplete object remains
  `IncompleteInput`, not `eof-value`. The source is copied into owned Rust storage before the reader
  borrows it. Keyword arguments use the shared parser (odd tail, unknown names, leftmost duplicate,
  `:ALLOW-OTHER-KEYS`).
- **`EVAL` (M18):** `(eval form)` evaluates `form` in `Scope::EMPTY`. It sees global functions and
  macros and the current dynamic special bindings. It does not see caller lexical variables,
  functions, macros, or blocks. The complete `Values` packet is preserved; `Flow` / `Unwind`
  propagate. The form is rooted across re-entry.
- **`LOAD` (M34):** `(load pathname &key print)` reads the UTF-8 file named by the string `pathname` (a
  relative path is relative to the process's current directory; no pathname objects) and evaluates its
  top-level forms one at a time in source order, each read just before it is evaluated, in `Scope::EMPTY`
  as `EVAL` does (global functions, macros and current dynamic bindings are visible). It returns the single
  value `T`; `:print` true prints each form's values, one per line, as the REPL would. A leading byte order
  mark is dropped. Earlier forms keep their effects when a later one fails. A missing, unreadable or
  non-UTF-8 file is `LispError::Stream` naming the path, a condition `HANDLER-CASE` can take like a failed `OPEN`
  (ADR 0022, amended; it was an unadapted `Io` error before). An error that no handler took comes back as
  `LispError::Load { file, line, column, cause }` (1-based, character column, the start of the top-level
  form being read or evaluated; `cause` is the original error); an error a `HANDLER-CASE` takes is the
  ordinary condition, unwrapped; `THROW`, `RETURN-FROM` targets outside the file, `UNWIND-PROTECT`
  cleanups and `RUSTLISP-EXIT` pass through `LOAD` unchanged. `:verbose`, `:if-does-not-exist`,
  `:external-format`, `*load-pathname*` and `COMPILE-FILE` are not provided. `LOAD` is a builtin, so it is
  a protected function name. It adds one level to the evaluator depth. See
  [interactive development](interactive-development.md).
- **Printer modes (M18).** One printer, two modes. Readable (`PRIN1`, host `Interp::print`) is
  unchanged. Aesthetic (`PRINC`) prints string contents without quotes, a character without `#\`
  syntax, a keyword without its colon (M38), symbols with the current pname formatting, and lists by
  traversing as today with aesthetic elements. Cycle and depth policy is shared.
- **`PRINC` (M18):** `(princ object &optional output-stream) => object`. Aesthetic text is rendered
  into owned Rust text, then written through `HostOutput`. A failed write is `LispError::Io` and
  does not update beginning-of-line.
- **`PRIN1-TO-STRING` (M18):** `(prin1-to-string object) => string`. Readable printer; one fresh
  Lisp string. The argument is rooted across allocation.
- **`FRESH-LINE` (M18):** `(fresh-line &optional output-stream)`. If already at beginning of line:
  emit nothing, return `NIL`. Otherwise write one newline, set beginning-of-line only on success,
  return `T`.
- **`CONCATENATE` (M18, generalised in M40):** `(concatenate type sequence...)` with the result types `LIST`, `VECTOR`
  (`SIMPLE-VECTOR`, `(VECTOR T)`) and `STRING` (`SIMPLE-STRING`, `(VECTOR CHARACTER)`); every source is a list, string or
  vector. A string result needs character elements (`Type` expected `"character"`); a source that is not a sequence is `Type`
  expected `"sequence"`; any other result type is `NotImplemented`. In M18-M39 only `STRING` and string sources existed.
- **`STRING-TRIM` (M18/M41):** `(string-trim bag string)` accepts a character sequence
  (list/vector/string) as its bag and a string designator as input. `bag` is the
  explicit set of characters to remove from both ends by scalar equality, not a whitespace
  predicate. Interior matches stay. Always a fresh string.
- **`CHAR-UPCASE` / `CHAR-DOWNCASE` (M18):** one Lisp character in, one out. Rust Unicode case
  mapping; if that mapping is exactly one scalar, use it; if it is several scalars, return the
  original character. No locale. ASCII is pinned; `ß` uppercases to `ß` under this rule (`to_uppercase`
  yields `SS`).
- **`COERCE` subset (M18, extended in M40):** between lists, strings and vectors: result types `LIST`, `VECTOR`/`SIMPLE-VECTOR`
  and `STRING` (a list stays itself when it is already a list; every other result is fresh; a string result needs
  characters; circular and dotted lists are type errors). Other result types (numbers, functions) are `NotImplemented`.
- **Wizard textual REPL (M18).** `lisp/wizard-game.lisp` is a rustlisp fixture: the world, names, and
  prose are original; the command-loop structure follows the Land of Lisp Wizard example; `TWEAK-TEXT`
  and `GAME-REPL` are depth-safe so they fit this evaluator. Commands are
  ordinary lines (`look`, `walk east`, `pickup lamp`, `pick lamp`, `drop lamp`, `inventory`, `help`, `quit`) processed in Lisp:
  `READ-LINE` → wrap in parentheses → `READ-FROM-STRING` → quote arguments → `GAME-EVAL`.
  `*command-specs*` names each command, its exact argument count, and its usage string.
  A known command with the wrong count returns that usage string and does not call the
  command function. An unknown command returns "I do not know that trick." and is not
  evaluated. A known command with the right count is evaluated only if it is also on
  `*allowed-commands*` (`LOOK`/`WALK`/`PICKUP`/`PICK`/`DROP`/`INVENTORY`/`HELP`).
  `GAME-PRINT` is `PRIN1-TO-STRING` / `STRING-TRIM` / `COERCE` / depth-safe `TWEAK-TEXT` /
  `PRINC` / `FRESH-LINE`. `LOOK` returns one flat word list so player text does not expose
  nested-list parentheses. `PICKUP` prepends `(object BODY)` onto `*thing-places*`. `DROP`
  of a carried object replaces every association for that object with one
  `(object <current room>)` entry; an object that is not carried is refused and the world
  is left unchanged. `GAME-REPL` uses simple `LOOP`. Exact `QUIT` (no arguments) is not
  evaluated and returns `NIL`. `QUIT` with extra words prints `Usage: quit` and the loop
  continues. Direct calls such as `(walk)` still use the interpreter's ordinary closure
  arity errors. `tests/wizard_repl.rs` covers this Wizard application loop
  (`GAME-READ` / `GAME-EVAL` / `GAME-REPL`, commands, and world state). It is
  not a generic Lisp `SIMPLE-REPL`. The published recursive `TWEAK-TEXT` and
  `GAME-REPL` still exceed `MAX_EVAL_DEPTH`; rustlisp does not claim that unchanged published Wizard
  source runs. The M18 claim is that a depth-safe Lisp implementation of the same textual interface
  runs.
- **Standalone Wizard executable (M19).** `cargo build --release --bin wizard-game` produces a
  native binary that embeds `lisp/wizard-game.lisp` at compile time, loads Layer 0 via
  `Interp::standard()`, evaluates the embedded game, and calls `(game-repl)` on default host
  stdin/stdout. The developer REPL is not used. Recipients of that binary need the executable, not
  Rust, Cargo, rustlisp, or the Lisp source file as a runtime file. `QUIT` and entry-phase
  end-of-file exit 0 without printing a Lisp result. Other errors print to stderr and exit 1.
  Arguments are rejected (`usage: wizard-game` on stderr, exit 1). This is interpreted embedded
  Lisp, not Lisp-to-native compilation. The artifact is platform-specific and may still require
  ordinary OS dynamic libraries. No environment variable is required; the existing
  `RUSTLISP_GC_POLICY` / `RUSTLISP_GC_THRESHOLD` controls remain inherited.
- **Cross-platform Wizard artifacts (M20).** M20 adds no Lisp or runtime semantics.
  Native `wizard-game` binaries for Linux x86_64, Windows x86_64, and macOS arm64 are
  produced as GitHub Actions workflow artifacts. Recipients still run the same
  interpreted embedded fixture as M19.
- **`DEFVAR` / `DEFPARAMETER` (M13A):** native derived forms (macros in Common Lisp).
  `(defvar name [init [documentation]])` proclaims `name` globally special. With no init it returns
  `name` and leaves any value unchanged. With init it evaluates init only if the dynamic variable is
  unbound (no active dynamic binding and no global cell; a lexical binding does not count) and stores
  the result in the **global** value cell. `(defparameter name init [documentation])` always evaluates
  init and assigns the innermost dynamic binding or else the global cell. Documentation is an
  unevaluated string, accepted and discarded; `(defvar x "doc")` treats the string as the initializer.
  A syntax or constant error does not proclaim. A failed init leaves the proclamation and does not
  assign. `#'defvar` is `UndefinedFunction`. Stars in a name are a convention only.
- **Functions are first-class objects** (builtin functions and lexical closures). `(function name)` returns the
  function object currently denoted by `name` in the *function* namespace (never the variable of the
  same name): `(function list)` is the `LIST` function even after `(setq list 42)`. It signals
  `UndefinedFunction` if there is none (including for special-operator names such as `if`), and an
  arity error unless it has exactly one operand. `(function (lambda ...))` creates a closure (see
  below); other operands are syntax errors.
  - Function objects print as `#<FUNCTION LIST>` (diagnostic, not readable). `EQ` is object identity:
    `(eq (function list) (function list))` is `T`. They are true, atoms, and not conses: `CONSP` is
    false and `CAR`/`CDR`/`RPLACA`/`RPLACD` signal type errors.
  - `FUNCTIONP`: true for a function *object*. A symbol that names a function is a function designator,
    not a function, so `(functionp 'list)` is `NIL`; `(functionp 42)` is `NIL`.
  - `FUNCALL`: `(funcall designator arg*)` evaluates the designator and the arguments normally, then
    calls the function. The designator is a function object (it denotes itself) or a symbol, which
    denotes its **global** function definition: `(funcall 'list 1 2)` is `(1 2)` even if the *variable*
    `list` has been set to 99. A quoted symbol never resolves through the variable namespace (and, when
    lexical functions exist, never through them). Other objects are a type error; an unknown name is
    `UndefinedFunction`. `(funcall #'funcall ...)`-style chains work.
  - `APPLY` (M8B): `(apply designator arg* final-list)`, an ordinary builtin (its operands are evaluated normally; it is
    not a special operator, so `#'apply`, `(funcall #'apply ...)` and `(apply #'apply ...)` work, and `APPLY` is a
    protected function name). It calls the function with the explicit arguments followed by the elements of the final
    list, in that order: `(apply #'+ '(1 2 3))` is `6`, `(apply #'+ 1 2 '(3 4))` is `10`, `(apply #'f 1 2 nil)` passes
    exactly `1` and `2`. **At least two arguments** are required (`(apply #'f)` is `ArgCount`, "APPLY: expected at least
    2 argument(s), got 1"). The designator is coerced exactly as for `FUNCALL`: a function object (`#'f`, including a
    lexical function and a saved closure) denotes itself, a quoted symbol denotes its **global** function (never a
    lexical one), anything else is a type error or `UndefinedFunction`, reported before the final list is examined. The
    **final argument must be a proper list**: `(apply #'f 1)`, `(apply #'f '(1 . 2))` and a non-cons object are a
    `Type` error ("expected proper list") and nothing is called; a dotted tail is never an extra argument. **The
    effective argument count (explicit arguments plus list elements) may not exceed `MAX_CALL_ARGUMENTS`**, whichever
    caller reaches `APPLY` (including a host calling the builtin through `Interp::apply`); a longer call, and in
    particular a **circular** final list, ends in the same over-limit `InvalidSyntax` error that an over-long call form
    gives. That diagnostic is a deterministic rustlisp safeguard, not an ANSI-mandated condition (there is no cycle
    detection, only the bound). Argument-count and type checking of the call itself belong to the callee, exactly as for
    `FUNCALL` (`ClosureArgCount`, `ClosureArgCountAtLeast`, builtin `ArgCount`); `RETURN-FROM`, `THROW` and
    `UNWIND-PROTECT` pass through `APPLY` as through `FUNCALL`. A `&REST` parameter of the callee receives a **fresh**
    list (a rustlisp implementation policy, see above): `(apply #'collect source)` never shares structure with `source`.
    `APPLY` and `FUNCALL` propagate the callee's complete internal packet; with no Lisp-visible producer yet, that is
    still one observable value.
  - **Four separate things:** variables (`(setq list 42)`; `list` is 42), functions (`(list 1 2)` is
    `(1 2)`), special operators (`(setq if 5)` leaves `(if if 'a 'b)` working) and symbols themselves
    (`'list` is just the symbol). `foo` unbound is `UnboundVariable`, `(foo)` undefined is
    `UndefinedFunction`, `(function foo)` undefined is `UndefinedFunction`.
  - Operator position takes a symbol (a function name) or a lambda expression (a lambda form).
    `((function list) 1 2)`, a function *object* in operator position, is not supported.
- **Closures.** `(function (lambda lambda-list body...))` returns a lexical closure that captures the
  current lexical scope (variables, lexical functions, and lexical blocks) and has indefinite extent. The
  lambda list and body are validated but **not evaluated** when the closure is created, so
  `(function (lambda (x) (car 10)))` succeeds and the error appears only when it is called.
  - **Lambda lists (M8A, M8C, M12):** `(required-var* [&optional {var | (var [init-form [supplied-p-var]])}*] [&rest rest-var] [&key {var | ({var | (keyword-name var)} [init-form [supplied-p-var]])}* [&allow-other-keys]] [&aux {var | (var [init-form])}*])`:
    `(lambda (x y) ...)`, `(lambda () ...)`, `(lambda (a &optional (b 10 bp)) ...)`, `(lambda (&rest r) ...)`,
    `(lambda (a &optional b &rest r) ...)`, `(lambda (&key x (y 1 yp) ((:color c) 1)) ...)`,
    `(lambda (&key x &allow-other-keys) ...)`, `(lambda (x &aux (y x)) ...)`, the same for `DEFUN`, `FLET` and `LABELS`.
    Every genuine parameter must be a symbol other than `NIL`/`T`/keyword symbols and may not be a lambda-list keyword.
    **Every genuine parameter name (required, optional, supplied-p, rest, key local, key supplied-p) must be distinct**,
    and duplicate external key names are rejected: a rustlisp restriction, not a claim that ANSI requires this diagnostic.
    **`&AUX` names are sequential (`LET*`-like) and may shadow** an earlier parameter or earlier aux binding; `NIL`/`T`/keywords remain `ConstantVariable` as aux names.
    The total number of names, including aux occurrences, is bounded by `MAX_LAMBDA_PARAMETERS`, an implementation safeguard and
    not an ANSI limit (counting aux is a conservative rustlisp resource policy).
    The `&REST` variable is an ordinary lexical variable bound to a **fresh proper
    list** of the arguments left after the required and optional ones, in call order (`NIL` when there are none); a new list is
    built on every call (an implementation choice, not a portability guarantee: ANSI permits an implementation to share the rest list with the
    final argument of `APPLY`, and rustlisp deliberately never does). It can be `SETQ`ed, captured and destructively modified like any list.
    A missing `&REST` variable, a second `&REST`, an extra symbol after the `&REST` variable, a non-symbol or an
    improper list is `InvalidSyntax`; `&OPTIONAL` after `&REST` and a second `&OPTIONAL` are `InvalidSyntax`.
    **`&OPTIONAL` (M8C).** A bare `var`, `(var)` and `(var nil)` are the same: omitted means `NIL`. `(var init-form)`
    evaluates `init-form` **at each call that omits the argument** (never when the argument is supplied, never when the
    closure is created, so a failing init form is an error only when needed). `(var init-form supplied-p-var)` also binds
    `supplied-p-var` to `T` if the argument was supplied and `NIL` if it was omitted; "supplied" is decided by position,
    never by the value, so a supplied `NIL` is `T`: with `(lambda (&optional (x 10 xp)) (list x xp))` the calls with no
    argument, `NIL` and `20` give `(10 NIL)`, `(NIL T)` and `(20 T)`. An empty section is valid: `(&optional)` and
    `(&optional &rest r)` mean the same as the lists without it. A specifier of more than three elements, a dotted one, a
    non-symbol variable or supplied-p variable, a keyword used as a variable, and a repeated name are `InvalidSyntax`;
    `NIL`/`T` as a variable or supplied-p variable is `ConstantVariable`.
    **Order and scope.** After the argument count is checked, the required parameters are bound left to right, then each
    optional parameter in order: take the supplied argument, or evaluate the init form; bind the variable; bind its
    supplied-p variable; then the `&REST` list is built and bound; then keyword validation of that same surplus; then
    key bindings; then aux bindings; then the body. An init form is evaluated as if by
    `LET*`: it sees the closure's captured variables, functions and blocks plus every earlier required, optional and
    supplied-p binding (these shadow captured variables), but never its own variable or supplied-p variable, never the
    rest variable and never the caller's lexical environment. `(let ((b 5)) ((lambda (&optional (b b)) b)))` is `5`.
    `FLET` init forms see the outer function environment (not the `FLET`'s own definitions); `LABELS` init forms see the
    completed local environment. An optional variable lives in the variable namespace only.
    **Init forms and the implicit block.** The implicit `BLOCK` of `DEFUN`/`FLET`/`LABELS` surrounds the body forms, not
    the lambda list: `(defun f (&optional (x (return-from f 10))) x)` does not return through `f`'s own implicit block
    and signals `UnknownBlock` when the default is needed. An enclosing block that really is lexically visible where
    the function was defined is found by the ordinary lexical lookup (and is a control error once it has exited).
    Init forms are ordinary Lisp: an error stops the call before the body, and `RETURN-FROM`, `THROW` and
    `UNWIND-PROTECT` work in them as anywhere else.
    **`&KEY` (M12).** A bare `var` matches the keyword interned from its pname (`intern_keyword`). An explicit
    `((keyword-name var) ...)` matches that symbol by EQ/`SymbolId` identity (so `((:color c) ...)` matches `:COLOR`,
    while `((color c) ...)` matches ordinary `COLOR`). Matching is never by string. The leftmost complete caller pair
    for a given key supplies the value; later duplicates are still evaluated (function calls) and then ignored.
    The entire remaining argument sequence is validated before any missing key or aux init form runs. Without
    suppression, an odd remaining count, a non-symbol key name, or an unrecognized name is `InvalidSyntax`
    (rustlisp's stand-in for the eventual Common Lisp `program-error` condition). `:ALLOW-OTHER-KEYS` is always a
    recognized name when `&KEY` is present. Lambda-list `&ALLOW-OTHER-KEYS` suppresses checking regardless of the
    caller; otherwise only the leftmost `:ALLOW-OTHER-KEYS` pair controls, and a non-NIL value suppresses. A later
    true value does not override an earlier NIL. When suppressed, unknown names, non-symbol names and an odd leftover
    object are accepted (the leftover remains in `&REST` if any). Optionals are consumed positionally before keyword
    processing, so `(f :b 3)` with `(&optional a &key b)` binds `A` to `:B` and then sees an odd keyword tail.
    `&REST` and `&KEY` share the same remaining arguments: the rest list is a fresh copy; keyword processing does
    not mutate it. Key init forms see every binding to their left (including rest) and run outside the implicit
    named block, as optional init forms do.
    **`&AUX` (M12).** Aux variables are not supplied by the caller and do not change arity or rest contents.
    Default init is `NIL`. Each aux init sees all actual parameters and earlier aux bindings.
    `&body`, `&whole` and `&environment` belong to other lambda-list contexts and are
    merely recognised in ordinary lists and reported as unsupported. None is ever silently treated as a variable.
    Local `(declare (special ...))` in a lambda body is supported (M13B); other declaration identifiers remain
    `NotImplemented`. A documentation string in a lambda body that is followed by another form is
    recognised and discarded (not stored); a lone or final string is the body value.
  - **Lambda forms:** `((lambda (x) (+ x 1)) 5)` is `6`. It makes the same closure as `FUNCTION` and
    calls it like any other function; arguments are evaluated left to right first.
  - **`LAMBDA` is not a special operator** (it is a macro in Common Lisp). The evaluator recognises a
    lambda expression as the operand of `FUNCTION` and in operator position. **M31:** the `LAMBDA`
    macro by itself, `(lambda (x) x)`, is defined in Layer 0 as `(function (lambda . definition))`, so
    it makes the same closure as `#'(lambda (x) x)` with the same lambda-list subset and the same
    errors (`&BODY`, `&WHOLE`, `&ENVIRONMENT` stay `NotImplemented`). It is part of `Interp::standard()`
    only: in the bare kernel `(lambda (x) x)` is an undefined function. `LAMBDA` is no longer a
    protected name; like `WHEN` it can be redefined. See [planner.md](planner.md).
  - **Calling:** with neither `&optional` nor `&rest` nor `&key` the argument count must match exactly (`ClosureArgCount`); with
    `&optional` and no `&rest`/`&key` it must lie between the number of required parameters and required plus optional
    (`ClosureArgCountRange`, "anonymous function expected between N and M argument(s), got K"); with `&rest` or `&key`, at least the
    number of required parameters is needed (`ClosureArgCountAtLeast`) and any surplus beyond the optionals goes to the
    rest list and/or keyword processing. `&AUX` does not change caller arity. An odd keyword tail is `InvalidSyntax`,
    not an arity error. An arity error is signalled *before any init form or body form runs*. Each call binds the
    parameters in fresh bindings on top of the captured environment (not the caller's), classified at
    this call from the proclamations then in force and from the closure's `declared_specials`
    metadata: a globally special name or a bound local `SPECIAL` declaration is dynamic plus a
    per-call Declare mark when needed; otherwise lexical, with a Shadow mark when inherited
    visibility is Declare. Free `SPECIAL` declarations overlay the body after every parameter is
    bound. The stored closure is not mutated. They
    shadow captured variables and leave them unchanged. The body is an implicit `PROGN` (an empty
    body returns `NIL`).
  - **Lexical scope:** `(let ((x 1)) (let ((f (function (lambda () x)))) (let ((x 2)) (funcall f))))`
    is `1`. Global variables are looked up when the closure is called.
  - **Closures capture bindings, not values:** `(let ((x 1)) (let ((f (function (lambda ()
    (setq x (+ x 1)) x)))) (list (funcall f) (funcall f))))` is `(2 3)`; two closures made in one scope
    share their captured bindings (`(1 1 2 2)` for an increment/read pair); each call of the creating
    function makes new, independent bindings (`(funcall make-adder 10)` and `(funcall make-adder 20)`
    are independent adders).
  - **Indefinite extent:** `(setq add10 (funcall make-adder 10))` followed by `(funcall add10 5)` is
    `15`, even after garbage collection between the two.
  - **Identity:** a closure is an object: `(eq f f)` is `T`; two closures created separately are not
    `EQ` even from identical source. `FUNCTIONP` is true; it is not a cons. Printed as
    `#<FUNCTION (LAMBDA ...)>`.
  - **Recursion** is possible by self-application (`(funcall self self ...)`), within deliberately
    finite limits: the compiled machine's frame limit (100,000 frames; a call in tail position keeps
    none) and the evaluation depth limit (80 units for a bare `Interp::new()`, 10,000 in the shipped
    binaries since M42), which in the machine counts only calls back into compiled code from a
    builtin, deep nesting while compiling and top-level forms, and in the tree walker every
    evaluation. Exceeding either signals a controlled control-stack-exhausted error. The limits
    are implementation safeguards, not language rules (see
    [Evaluation by the compiled machine](#evaluation-by-the-compiled-machine-adr-0064)).
- `LET`, special operator: `(let (binding*) body*)` with binding `var`, `(var)` or
  `(var init-form)` (the first two bind `NIL`). Common Lisp `LET` semantics: all init forms are
  evaluated left to right in the **outer** environment, so `(let ((x 10)) (let ((x 20) (y x)) y))`
  is `10`, and a variable is not visible in its own init form (`(let ((x x)) x)` is unbound if there
  is no outer `x`). Leading `(declare (special ...))` forms are parsed before any initializer runs
  and do not apply to initializer forms. After the inits, each binding is classified from the
  proclamations then in force and from bound local `SPECIAL` names (an init may `DEFVAR` and make a
  binding of this `LET` dynamic). A dynamic name is a dynamic binding plus a Declare mark when
  visibility needs one. An ordinary name is lexical, with a Shadow mark when inherited visibility is
  Declare. Free `SPECIAL` names overlay the body contour. The body is an implicit `PROGN`; an empty body returns `NIL` (`(let ())` is
  `NIL`). Bindings shadow outer ones and are undone at the end of the `LET`. Aliasing works as
  expected: `(let ((x (list 1 2))) (let ((y x)) (rplaca y 9) x))` is `(9 2)`.
  Errors: no arguments is an arity error; a malformed binding list or binding (not a symbol or list,
  a non-symbol variable, more than `(var init-form)`, dotted lists) is a syntax error; binding `NIL` or
  `T` (constants) is a constant-variable error and is never silently shadowed; **a variable named
  twice in one `LET` is currently rejected as a syntax error. This is a rustlisp restriction and
  implementation choice; this document does not claim that ANSI Common Lisp requires the
  diagnostic.** Nothing is evaluated if any binding specification is invalid.
  Not supported: declaration identifiers other than `SPECIAL`, the advisory ones of M60 and the abbreviated type declarations of M67 (`NotImplemented`), destructuring.
  `DECLARE` as an executable body form (not a leading declaration) remains `NotImplemented`.
- `CONS`, `CAR`, `CDR` (`CAR`/`CDR` of `NIL` is `NIL`).
- `APPEND` (M9C1): `(append list* object)`. `(append)` is `NIL`; `(append x)` is `x` itself, any object; every argument except the last
  must be a finite **proper list** whose cons spine is **copied** (the elements are shared, not copied); the last argument may be any
  object and is **shared** as the tail of the result, so `(append '(a b) 'c)` is `(A B . C)`. No argument is modified. A dotted list, a
  non-list or a **circular** list in a non-final position is a `Type` error ("expected proper list"); circularity is detected exactly,
  so a legitimately long list is accepted (its length is not limited by `MAX_CALL_ARGUMENTS`), and a circular *final* argument is
  merely shared. All arguments are checked, left to right, before anything is built. `APPEND` is a protected name.
- `LIST`: a normal function; `(list)` is `NIL`, otherwise it returns a fresh proper list of its
  evaluated arguments, one new cons per argument.
- **Property lists (M15).** An ordinary list of indicator/value pairs
  `(indicator-1 value-1 indicator-2 value-2 ...)`. Indicators and values may be any objects.
  Comparison is existing `EQ` (so current-home `FOO` and keyword `:FOO` are different indicators,
  and two conses with equal contents are different indicators unless they are the same object).
  Duplicate indicators are preserved; the **first** matching pair wins. A stored `NIL` is a
  present property, distinct from absence. The list is the caller's cons structure: it is not
  copied, sorted, deduplicated, or converted to a host map. There is no symbol-plist storage
  (`SYMBOL-PLIST`, `GET`, `REMPROP`, `REMF` and `SETF` of `GET`/`SYMBOL-PLIST` remain unimplemented; `SETF` of `GETF` is the M49 expander above).
  - **`GETF`:** protected builtin `(getf plist indicator &optional default)`, one value. Scans
    from the beginning; a hit returns that pair's value; absence returns `default` or `NIL`.
    Ordinary function-call evaluation: `plist`, `indicator` and a supplied default are all
    evaluated before `GETF` runs, even when the property is present.
  - **`GET-PROPERTIES`:** protected builtin `(get-properties plist indicator-list)`, exactly
    three values. `indicator-list` is a finite proper list of membership criteria (not a
    priority order); it is validated before `plist` is walked. A hit returns the matching
    indicator, its value, and the **actual original cons** whose car is that indicator (the
    tail is `EQ` to that cell of the input, not a copy). Search order is **plist order**, so
    `(get-properties '(a 1 b 2) '(b a))` yields `A`, `1`, and the tail beginning at `A`.
    A miss, including an empty indicator list, is three `NIL`s (not one `NIL` and not zero
    values). An empty indicator list does not inspect `plist`.
  - **Malformed lists (rustlisp policy; ANSI is undefined).** Pairwise walk with Floyd cycle
    detection on the cdr chain and no length bound (`MAX_EVAL_DEPTH` / `MAX_CALL_ARGUMENTS`
    do not apply). Termination is guaranteed. A match found wholly before malformed structure
    is returned without looking further. A walk that needs a cons and finds a non-`NIL` atom,
    or an indicator with no following value cell, is `Type { expected: "property list" }`.
    If a valid matching pair is encountered before the cycle detector fires, that match may
    be returned; otherwise entering or traversing a cycle ends in the same Type error
    (`got` is `"a circular list"`). Matches reachable only after crossing a cycle back-edge
    are intentionally unspecified. There is no infinite loop. A malformed `indicator-list`
    is the existing proper-list `Type` error.
- `EQ`: object identity. Two arguments. True for the same symbol (so `(eq nil 'nil)` is `T`,
  `(eq 'a 'A)` is `T`) and for the same heap object (same handle). Structurally equal but separately
  allocated conses and strings are not `EQ`: `(eq (list 1) (list 1))` is `NIL`; `(eq "a" "a")` is
  `NIL` for separately read literals, while `(let ((s "a")) (eq s s))` is `T`. `(eq (list) nil)` is `T`, since
  both are the single canonical `NIL`. `EQ` on integers and on characters happens to compare values
  here (characters are immediate Unicode scalars, so `(eq #\A #\A)` is `T`), but that is rustlisp
  behaviour the standard leaves unspecified for those types; portable code uses `EQL` for numbers
  and characters, and `CHAR=` / `STRING=` for character and string comparison.
- **`EQL` (M17):** two-argument protected builtin. Integers compare by numeric value (`(eql 1 1)` is
  `T` even if they are not the same object in some implementations); characters compare by Unicode
  scalar; everything else is `EQ`. `(eql 1 1)` is `T`; `(eql #\A #\A)` is `T`; `(eql (list 1) (list 1))`
  is `NIL`. M27 adds Lisp-prelude `EQUAL`; `EQUALP` remains absent.
- **Composed `C[AD]{2,4}R` (M17):** the 28 standard names (`CAAR` … `CDDDDR`) are ordinary Layer 0
  Lisp over `CAR`/`CDR`. They exist in `Interp::standard()`, not the bare kernel, and occupy ordinary
  redefinable operator slots. `(cadr '(a b c))` is `B`; `(cadr nil)` is `NIL`.
- **List search and mapping (M17).** Protected ordinary functions. Default item comparison is `EQL`
  (never `EQ` directly). `:KEY` is identity when omitted or `NIL`; otherwise a function designator
  applied only to the sequence or alist element. `:TEST` and `:TEST-NOT` are mutually exclusive;
  both supplied is `InvalidSyntax`. Test-function argument order is `(item transformed-element)`.
  Leftmost duplicate keyword wins; `:ALLOW-OTHER-KEYS` follows `&KEY`. Walks are iterative; list
  length is not bounded by `MAX_EVAL_DEPTH` or `MAX_CALL_ARGUMENTS`. Malformed or circular policy
  matches M15: an early match may return before a later dotted or cyclic tail is examined; otherwise
  `Type` (`got` `"a circular list"` on a cycle). Callbacks (`:KEY`, `:TEST` / `:TEST-NOT`, predicate,
  mapper) run through `apply_flow`; extra values are discarded and zero values behave as `NIL`.
  The walker captures and roots the next tail (and, for `ASSOC`, the current entry) before invoking
  Lisp callbacks. Destructive shortening of the already-visited or current source linkage does not
  invalidate that captured next step. Callbacks that arbitrarily lengthen or restructure future
  traversal have unspecified effects.
  - **`ASSOC`:** `(assoc item alist &key :test :test-not :key)`. Returns the first matching cons, or
    `NIL`. Outer-spine type is `"association list"`; a `NIL` entry is skipped; a non-`NIL` atomic
    entry is `Type` expected `"cons"`.
  - **`MEMBER`:** `(member item list &key :test :test-not :key)`. Returns the matching tail cons, or
    `NIL`.
  - **`FIND`, `FIND-IF` (M17, rewritten in M40):** now part of the Rust sequence library: `(find item sequence &key
    :test :test-not :key :start :end :from-end)` on a list, string or vector, returning the original matching element or `NIL`;
    `FIND-IF` takes a predicate and no test. See [data-structures.md](data-structures.md). The public Chapter 5 Wizard
    `WALK` uses `FIND`.
  - **Core library (M32).** Details, limits and the audit: [core-library.md](core-library.md).
  - **`=` `<` `>`:** protected builtins over `i64` only, one or more arguments (none is an arity
    error); every argument is type-checked even after the result is decided; `<`/`>` compare adjacent
    pairs strictly; exact at `i64::MIN`/`MAX`. Not general numeric comparison.
  - **`FIRST` `REST`:** Layer 0 functions identical to `CAR` / `CDR` (not `SETF` places).
  - **`REVERSE`, `REMOVE` (M32, moved to Rust in M40):** protected builtins over lists, strings and vectors; see
    [data-structures.md](data-structures.md). The test is still called as `(test item (key element))`, default `EQL`; the result
    is always fresh; `:start`, `:end` and `:from-end` are supported.
  - **`DOLIST` (M32, rewritten in M44):** Layer 0 macro. `GENSYM` names the traversal, so the
    bound variable is the only name the body can see. The list form runs once. The variable is
    bound afresh for each element and is `NIL` in the result form. `RETURN` leaves the implicit
    `BLOCK NIL`. A dotted tail is a `Type` error after the proper prefix has been visited. A
    circular list is a `Type` error from `LENGTH`. The walk is simple `LOOP`, so the body costs
    the same as `(loop (return ...))`: at the 80-unit library default a recursive body reaches
    13 levels (a bare call reaches 14).
- **`MAPCAR`:** `(mapcar function list &rest more-lists)`. At least one list. Stops when any list
    reaches `NIL` and does not inspect excess tails of longer lists. Result is a fresh proper list
    built front-to-back.
  - **`REMOVE-IF-NOT`:** now the Rust sequence library's (M40): `(remove-if-not predicate sequence &key :key :start
    :end :from-end :count)` returning a fresh object of the argument's kind.
- `CHARACTERP`, `STRINGP`: one argument.
- `CHAR`, `SCHAR`: `(char string index)` and `(schar string index)`; 0-based character index. Every
  M11 string is simple, so the two functions agree. Negative and out-of-range indexes are a type
  error (`expected: "a valid character index"`). No `SETF`.
- `CHAR=`: one or more characters, case-sensitive Unicode-scalar equality.
- `STRING=`: two string designators (a string, a symbol, or a character) compared case-sensitively as character
  sequences. Since M39 it takes the ANSI `&key :start1 :end1 :start2 :end2` too (see [text composition](text-composition.md));
  in M11-M38 it was the two-argument subset.
- `LENGTH`: `NIL`, a proper list, a string (character count) or a vector (its fill pointer when it has one). A dotted or
  circular list is a type error via the existing proper-list walk. Other types are `Type { expected: "sequence", ... }`.
- `RPLACA`, `RPLACD`: ordinary functions of two evaluated arguments. The first must be a cons;
  its car (or cdr) is replaced *in place* and that same cons is returned, so every alias observes
  the change and `(eq x (rplaca x 1))` would be true. `(rplaca nil 1)` and `(rplacd 10 1)` are type
  errors (`NIL` is a list but not a cons). Circular structure can be created this way
  (the heap, collector and printer support it).
  **Destructive modification of quoted/literal structure has undefined consequences, consistent
  with Common Lisp. The current interpreter does not attempt to protect literal objects from
  modification.**
- Predicates (each takes one argument and returns `T` or `NIL`): `NULL` is true only for `NIL`;
  `CONSP` is true only for cons cells; `ATOM` is true for everything that is not a cons, including
  `NIL`. Since `NIL` is both a symbol and the empty list: `(null nil)` and `(atom nil)` are `T`, and
  `(consp nil)` is `NIL`.
- `+`, `-`, `*` over integers: `(+)` is 0, `(*)` is 1, `(- x)` negates, `(- a b ...)` subtracts.
- Calls to built-in functions, with left-to-right argument evaluation and arity checking.
- Printing of integers, symbols, `NIL`, characters, strings, lists and dotted pairs. `(QUOTE x)` is printed in full, not
  abbreviated to `'x`.

## Partially implemented

- Numbers: exact integers and ratios, plus finite double-floats. Complex numbers,
  distinct float formats, `RATIONALIZE` remains absent. See numeric operations below.
- The printer: no `*print-...*` variables. Cyclic structure, nesting deeper than 256 and output beyond
  1,000,000 conses are cut off with `...`. This is a diagnostic format (e.g. `(A ...)` for a cdr-cycle),
  not Common Lisp circle notation, and it cannot be read back. The two limits apply to diagnostics only:
  `FORMAT` (`~S`, `~A`), the REPL's display of results and error messages. `PRIN1`, `PRINT`, `PRINC`, `WRITE` and
  the `-TO-STRING` functions print an object in full or signal an error (`the object cannot be printed in
  full`) and write nothing, so data a program saves is never silently incomplete; they still print a cycle
  with `...`. Data saved with `(format stream "~S" object)` is cut off as before: use `PRIN1` or `WRITE`.
- `SYMBOLP` (M28A) is true for every symbol, including `NIL`, `T` and keywords. `LISTP` (M24, Layer 0)
  recognizes NIL and all conses; other predicates include `EQ`, `EQL`, `NULL`, `ATOM` and `CONSP`.
- `SYMBOL-NAME` (M28A) returns the name as a string (no keyword colon; the reader folds ASCII case only, so
  `'λx` is named `"λX"`). It returns a *fresh* string on every call, so `(eq (symbol-name 'a) (symbol-name 'a))`
  is `NIL` where ANSI gives `T`; strings are immutable here, so this is observable only through `EQ`.
- Symbols have no value cell, function cell, plist or package.

## Not implemented

Implementation safeguards (not language semantics): evaluation nesting depth, reader nesting depth and
the number of arguments in one call are capped. Runaway nesting gives a controlled
control-stack-exhausted error (and a circular argument list a syntax error). The limits' values are
deliberately conservative, are not part of the language, and may change or go away once the evaluator
has an explicit control stack. Comparison operators: `=`, `<`, `>` over `i64` only (M32; no `<=`, `>=`, `/=`).
M27 implements `OR` as a Lisp macro (see below).

The variable model after M13B: lexical variables, globally proclaimed specials (`DEFVAR` /
`DEFPARAMETER`), dynamically scoped local bindings of proclaimed names, lexical
`(declare (special ...))` (bound, free, and Shadow), global value cells (also written by `SETQ`),
and the constants `NIL`/`T`/keywords. `DEFCONSTANT`, `CONSTANTP` and `PROGV` are now supported (ADR 0056);
`BOUNDP`, `SYMBOL-VALUE` and `MAKUNBOUND` arrived in M62. There is no
`PROCLAIM` (`DECLAIM` is the library's advisory macro); `SYMBOL-MACROLET` exists since M69.
`GET-SETF-EXPANSION` reads an environment object since M69. `DEFSETF` registers a short
updater or a long store-form expander. `DEFINE-SETF-EXPANDER` registers a
closure that returns the five values, and `&ENVIRONMENT` is bound to `NIL`.
No other `#` reader syntax (`#x`, `#b` and `#o` read integers since M54 and ratios such as `#xFF/2` since the review fixes;
`#nR`, `#n=` and `#n#` since M67). Declaration identifiers other than `SPECIAL`, the advisory ones and the
abbreviated type declarations are `NotImplemented`. `DECLARE` as an executable form remains `NotImplemented`. Lexical environments
remain the value namespace, plus a SpecialEnv contour whose first matching mark is Declare or Shadow.

`#n=`-labelled backquote templates, generalized `SETF` beyond the M16/M17/M40/M48 places,
complex numbers, multi-dimensional arrays, bit vectors, specialised arrays,
`DELETE-PACKAGE`, `UNINTERN`, package locks, `DEFPACKAGE :SIZE` as anything but a no-op, CLOS beyond the generic functions of M71 (classes, `DEFCLASS`, `MAKE-INSTANCE`, the metaobject protocol), compiler macros, a restart-listing debugger (M21B–M21D, M58 and M59 support `ERROR` and selected origin-signalled runtime errors with typed `HANDLER-BIND` observation and `HANDLER-CASE` recovery),
symbol property lists beyond `GET`/`REMPROP`, other predicates and list functions (see M64), `LOAD` options beyond `:PRINT` and `COMPILE-FILE`,
some `FORMAT` directives (`~< ~>`, `~/name/` and a few more; the rest of `FORMAT` is M39, [text composition](text-composition.md)), streams beyond the M37-M39 text subset (binary, bidirectional, `LISTEN`, pathnames; see [text I/O](text-io.md), [text and data processing](text-data.md) and [text composition](text-composition.md)), the evaluator trampoline,
and `COMPILE`. `#` dispatches other than `#'`, `#\`, `#(`, `#:`, `#x`, `#b`, `#o`, `#nR`, `#n=`, `#n#`, `#|`, `#+`, `#-`, `#.` and `#S` are rejected with a
`not implemented` error.

## Bind restarts (M21E)

`(restart-bind ((name function-form)*) body*)` establishes all restarts after
complete validation and left-to-right initialization in the outer environment.
Each primary result must be a function object, not a symbol function designator.
Names are unevaluated symbols; NIL establishes an anonymous restart. Body is
an implicit PROGN preserving all Values; empty body returns one NIL. Duplicate
names are allowed. Paired :test-function/:report-function/:interactive-function
options are NotImplemented before initialization; malformed/unknown options or
names are InvalidSyntax. No partial activation occurs.

`(invoke-restart name argument*)` is an ordinary function: operands evaluate
left-to-right. A non-NIL symbol selects the innermost active dynamic cluster and
its first source-order matching entry. Abandoned inner entries are skipped.
NIL and other invalid designators, or missing names, return ControlError. ANSI
Common Lisp signals CONTROL-ERROR; this implementation diagnostic is currently
outside adapted conditions. No restart objects or enumeration exist yet.

Invocation calls the function in the invocation dynamic environment without
inherent unwind. Zero/one/multiple result Values reach its caller unchanged.
Selected and sibling restarts remain visible, including recursive/nested calls.
Returning to a HANDLER-BIND handler allows continuation and normal decline; it
does not recover ERROR alone. Explicit RETURN-FROM/THROW skips the original
search, abandons crossed contours and runs cleanup after restart function entry.
Cleanup can invoke surviving outer restarts, return normally, or supersede the
pending transfer. Fresh cleanup restarts expire with their own extent. Specials
are observed at invocation and restored by existing binding ownership.

Runtime eligibility and handler suppression are unchanged; restart presence
is not handler interest. Options, FIND-RESTART/COMPUTE-RESTARTS/RESTART-NAME,
objects, RESTART-CASE, SIGNAL/WARN/CERROR, debugger and SIMPLE-REPL are deferred.
ADR 0019 records future M21F object and M21G condition/debugger roadmap seams.


## Implementation identity, CLI and termination (M22)

LISP-IMPLEMENTATION-TYPE and LISP-IMPLEMENTATION-VERSION take no arguments and
return "RustLisp" and the Cargo package version respectively. Since M35 the version is
`0.1.<milestone>` ([versioning](versioning.md)); `rustlisp --version` prints `RustLisp <version>` and the
terminal banner starts with the same line.

The developer executable accepts no arguments (REPL), --quiet (REPL without
banner), -e EXPRESSION (also combinable with --quiet), --version and --help.
Version/help exit successfully; invalid arguments exit 2. No file mode exists.
The banner requires both stdin and stdout terminals; quiet suppresses only the
banner. Existing prompts, multiline input and Ctrl-D/EOF remain supported.

Temporary nonstandard RUSTLISP-EXIT accepts zero or more :CODE/value pairs,
defaults to zero, and validates every pair before requesting termination.
The leftmost duplicate :CODE wins; all supplied values must be integers 0..=255.
Unknown keywords and malformed pairs are ordinary Lisp errors. QUIT is a
no-argument Layer 0 wrapper delegating to RUSTLISP-EXIT. There is no unqualified
EXIT. A `RUSTLISP` package, and therefore `RUSTLISP:EXIT`, is not installed.

Exit unwinds normally through pending UNWIND-PROTECT cleanup, retaining output.
It is not signalled and is not catchable by CATCH, HANDLER-CASE, HANDLER-BIND or
restart mechanisms. Existing dynamic targets become abandoned immediately.
Normal cleanup resumes exit. A later exit replaces the status; a cleanup error
replaces exit and the driver reports failure. An escaping cleanup transfer
follows existing rules, including errors for abandoned targets; fresh cleanup
blocks/catches/handlers/restarts work normally. A non-normal cleanup skips later
forms of that cleanup, while outer UNWIND-PROTECT cleanup still runs.

Host evaluation exposes EvalError::Exit separately from EvalError::Lisp;
the host decides whether to terminate its OS process. The developer REPL and
-e mode return the requested status, and fail with status 1 on an unhandled
cleanup error replacing exit. Ordinary REPL errors remain recoverable.
See ADR 0020 for boundary and rooting invariants.

## PAIP baseline (M24)

`LISTP` is an ordinary Layer 0 function of one argument, returning T for NIL
and every cons (proper, dotted or circular), NIL for every other represented
object. It does not walk the list, allocate a result, or validate properness.
Wrong arity follows ordinary closure diagnostics and origin signalling.
`Interp::new()` does not install it; `standard()` / `load_prelude()` do.
This matches the [ANSI LISTP contract](https://www.lispworks.com/documentation/HyperSpec/Body/f_listp.htm)
for the object kinds represented here.

The independent example in `examples/paip/grammar.lisp` expands data-driven
grammars through ordinary evaluation. Twelve controlled-choice cases are
covered by `tests/paip.rs`, including two recursive route segments and nullable
productions. At M24 the default random chooser was blocked by missing random-state
facilities; M25 enables it for positive integer bounds (see below). Controlled choices test expansion;
they are not a full Chapter 2 compatibility
claim. Unbounded recursive grammars still reach ControlStackExhausted.
See [the compatibility matrix](paip-compatibility.md) for audit scope and gaps.

## Random numbers and state (M25, ADR 0021)

RANDOM takes a positive integer bound (including a bignum) and optional random-state
object, returning an integer in [0,bound) and advancing that object. Omitted state resolves the
current real dynamic/global *RANDOM-STATE*; explicit NIL is a type error.
MAKE-RANDOM-STATE accepts omitted/NIL (copy current default), T (fresh random
initialization), or an existing state (independent copy without source
advancement). RANDOM-STATE-P is a one-argument predicate. All are ordinary
protected kernel functions. Arity/type errors follow existing origin signalling.

States have EQ/EQL object identity, not position equality. The globally special
*RANDOM-STATE* exists in the bare kernel; LET/parameter bindings and SETQ use
normal special-variable rules, and all dynamic exits restore object bindings
without resetting positions. Existing globals/dynamics/arguments/host roots
protect states; no new root category or Lisp-visible state slots exist.

`(random 1.0)` draws a double in `[0, 1.0)` from 53 unbiased random bits (M55). Bignum bounds use rejection sampling from unbiased chunks.
State print/read serialization is also
not implemented; printing is diagnostic #<RANDOM-STATE>. No full ANSI numeric
or random-state serialization conformance is claimed. SplitMix64 plus rejection
sampling avoids naive modulo bias; it is not for cryptographic secrets.
See [supported interfaces and examples](random.md).

## M26 list and sequence subset

Read-only NTH accepts nonnegative i64 indices, returns NIL beyond a proper list,
and supports finite indexing into dotted/circular lists when access reaches a
cons. NTHCDR (M28A) shares the same finite walk and returns the tail itself (no
copying; index 0 returns the list unchanged). A dotted tail reached after exactly
the requested number of CDRs is returned (`(nthcdr 1 '(a . b))` is `B`); a further
CDR of that atom, or a non-list argument even at index 0, is a type error, as in SBCL. ELT reads proper lists and Unicode strings and diagnoses invalid indices
or malformed list sequences. Since M40 ELT also reads vectors, and `(setf (elt ...))` and `(setf (nth ...))` are places. Bignum
indices remain unsupported.

NCONC and MAPCAN are ordinary Lisp prelude functions. NCONC destructively joins
noncircular intermediate lists (including dotted ones) to any final object.
MAPCAN maps one or more lists to the shortest length and joins callback primary
results without copying their spines or spreading result count through APPLY.
See [full supported contracts and defensive policies](list-sequences.md).
EQUAL, OR and LET* were measured gaps in M26; M27 implements them below.

## M27 structural equality, OR and LET*

Standard-image EQUAL compares supported finite data structurally: symbols by EQ,
i64/characters by EQL, strings by character content, cons CAR/CDR recursively in
meaning (iterative in implementation), and opaque objects by identity. Its
per-call memo gives a documented coinductive cyclic policy: two structures are
EQUAL when their unfoldings are, so cycles of different lengths can be EQUAL.
The memo is a union-find forest over the compared conses (the first 64 cons
pairs use none), so a comparison takes near-linear time in the conses visited.
It is read-only on inputs; mutations between calls are observed. No EQUALP or
numeric types added. `EQUAL` hash tables use the Rust comparison instead, which
signals an error for a key too large or circular to compare (M40).

Standard-image OR is a Lisp macro with left-to-right short-circuiting. A nonfinal
successful form returns only its primary; the final form returns all its values,
even when its primary is NIL or it returns zero values. Empty OR is one NIL.

LET* is a kernel special operator. It shares LET's accepted binding syntax and
upfront validation, but binds sequentially and permits repeated names. Lexical
closures retain earlier binding cells. SPECIAL bindings are restored after
initializer/body completion or any error/transfer/termination. Bound SPECIAL
scope starts with its binding; free declarations cover only the body. Other
declaration types remain unsupported. Final body values propagate unchanged.
See [the full contracts](tree-control-bindings.md). The
[Winston–Horn tracker](winston-horn-compatibility.md) is secondary to PAIP.
Its chapter index is imported. The current gaps for an exercise from either
book are the numeric tower, `DEFSTRUCT`, symbol plists and unification.
The exercise files under `examples/winston-horn/` were left as written.

## Numeric operations (M35, ADR 0023)

ADR 0057 extends the original bounded integer domain: i64 fixnums promote to
bignums on overflow and integral results demote when they fit again. `/` of exact
operands produces a reduced ratio, or an integer when the denominator is one.
Denominators are positive. Decimal integers, `#x`/`#b`/`#o` integers, decimal ratio
literals and `PARSE-INTEGER` support large integers. Ratios read as numbers rather
than symbols. Zero denominators are reader errors.

Exact numerators and denominators are limited to 1,048,576 bits each. Exceeding
that implementation resource limit is a controlled `Arithmetic` error (a `Read`
error for numeric literals). Complex numbers remain absent. The arithmetic and
comparison functions accept integers, ratios and floats; integer-only operations
reject ratios and floats. All levels, including the bare kernel, share the same
numeric representation and arithmetic. `NUMBERP`, `REALP` and `RATIONALP` remain
Lisp-layer functions; `INTEGERP`, `NUMERATOR`, `DENOMINATOR` and the representation
predicate `RUSTLISP-RATIO-P` are kernel primitives.

| Operation | Arguments | Result | Where |
|---|---|---|---|
| `+` `-` `*` | `+`/`*` any number, `-` at least one | checked sum, difference (negation for one argument), product | Rust (M0) |
| `=` `<` `>` `<=` `>=` | one or more | `T` when every adjacent pair satisfies the relation; every argument is type-checked first; one argument gives `T` | Rust (`<=` `>=` M35) |
| `/=` | one or more | `T` when **no two** arguments are equal (all pairs, not only neighbours); one argument gives `T` | Rust (M35) |
| `INTEGERP` | 1 | `T` for an integer, otherwise `NIL` (a type test) | Rust (M35) |
| `NUMBERP` | 1 | integers, ratios and floats | Layer 0 (M35) |
| `ZEROP` `PLUSP` `MINUSP` | 1 | `(= x 0)`, `(> x 0)`, `(< x 0)` | Layer 0 (M35) |
| `EVENP` `ODDP` | 1 | parity by `(rem x 2)`; correct for negative numbers and `i64::MIN` | Layer 0 (M35) |
| `1+` `1-` | 1 | `x + 1`, `x - 1`; promote as needed | Layer 0 (M35) |
| `ABS` | 1 | absolute value; `(abs i64::MIN)` promotes to a bignum | Layer 0 (M35) |
| `MIN` `MAX` | one or more | the smallest / largest argument (an argument, never computed, so no overflow); a single argument is type-checked and returned; the earlier of equal arguments is returned | Layer 0 (M35) |
| `TRUNCATE` `FLOOR` `CEILING` | dividend, optional divisor (default 1) | two values: quotient and remainder, rounding toward zero / negative infinity / positive infinity | Rust (M35) |
| `REM` `MOD` | exactly 2 | the remainder of `TRUNCATE` (sign of the dividend) / of `FLOOR` (sign of the divisor) | Rust (M35) |
| `GCD` | zero or more | greatest common divisor, never negative; `(gcd)` is 0, `(gcd n)` is `\|n\|` | Layer 0 (M36) |
| `LCM` | zero or more | least common multiple, never negative; `(lcm)` is 1; any zero argument gives 0 | Layer 0 (M36) |
| `INCF` `DECF` | place, optional delta (default 1) | the new value; exact arithmetic with promotion; see the place rules above | Layer 0 macro (M47) |

**Division.** `dividend = divisor * quotient + remainder` holds for every successful result, with
this table (checked against SBCL for all twelve sign combinations):

| dividend, divisor | `TRUNCATE` | `FLOOR` | `CEILING` |
|---|---|---|---|
| 13, 4 | 3, 1 | 3, 1 | 4, -3 |
| -13, 4 | -3, -1 | -4, 3 | -3, -1 |
| 13, -4 | -3, 1 | -4, -3 | -3, 1 |
| -13, -4 | 3, -1 | 3, -1 | 4, 3 |

The quotient is the primary value, so in a single-value context `(floor -13 4)` is `-4`; the
remainder is the second value (`MULTIPLE-VALUE-BIND`, `MULTIPLE-VALUE-LIST`, `MULTIPLE-VALUE-CALL`).
A divisor of zero is an `Arithmetic` error "division by zero" for all five functions, for every
dividend. A quotient beyond the fixnum range promotes, and exact remainders can
be ratios. `ROUND` uses nearest with ties to even. With a float operand the
remainder is a float. `/` is exact for exact operands: `(/ 13 4)` is `13/4`;
`(/ 8 2)` is `4`. There is no `QUOTIENT` alias. `NUMERATOR` and `DENOMINATOR`
accept rational operands (an integer has denominator one).

`EQL`/`EQUAL` compare separately allocated exact numbers by value. `EQ` of heap
numbers remains identity. `EQUALP` and numeric comparison compare exact real
values, including the exact binary value of floats: `(= 1/2 0.5)` is true while
`(= 1/10 0.1)` is false. Hash tables honor these equality rules. `FORMAT` radix
integer directives accept bignums; floating directives convert rational operands.
English/Roman `~R` remains limited to machine integers. General indices and OS
bounds remain machine-sized; integer `TAGBODY` tags remain i64.

Absent: the `F`-variants (`FFLOOR` ...) and bit operations beyond `LOGAND`,
`LOGIOR`, `LOGXOR`, `LOGNOT` and `ASH`.

**Redefinition.** `INTEGERP`, `<=`, `>=`, `/=`, `TRUNCATE`, `FLOOR`, `CEILING`, `REM` and `MOD` are
protected builtins (`DEFUN` of them is a `ProtectedFunctionName` error, as for `=`). The Layer 0 names
are ordinary operator slots (ADR 0011): a program may `DEFUN` its own `ABS`, `MAX`, `ZEROP` and so on,
and the other numeric functions do not depend on the replacement because they are written against the
protected builtins only. Using `1-` or `ZEROP` instead of `(- n 1)` or `(= n 0)` costs no recursion
depth at the deepest call (measured, `tests/numeric.rs`); the 80-unit library default (`Interp::new()`,
or `RUSTLISP_DEEP_RECURSION=0`) still allows about 14 levels of non-tail recursion, so a recursive factorial
is limited by evaluator depth, while the iterative form can produce bignums. The shipped binaries allow about 2,000 levels by default
since M42 ([deep-recursion.md](deep-recursion.md)); exact results are bounded by the implementation bit limit.

Examples that run unchanged under SBCL: [`examples/winston-horn/integers.lisp`](../examples/winston-horn/integers.lisp).

### Floating point (M55)

ADR 0044. `Value::Float` is an immediate double-float. **Every float format is the one double:** `1.5`,
`1.5e0`, `1.5d0`, `1.5f0`, `1.5s0` and `1.5l0` read as the same number and print as `1.5`; `(float x)` returns
a double (SBCL returns a single). A float is always finite: overflow, a division by zero, `(sqrt -1)` and the
like are `Arithmetic` errors, and a literal that overflows or underflows to zero is a `Read` error.
Number syntax: `[sign] digits . digits [exp]`, `[sign] . digits [exp]`, `[sign] digits [. digits] exp`;
`1.` is the integer 1.

- Printing is the shortest digit string that reads back, fixed from `1e-3` to below `1e7`, otherwise
  `1.0e7`, `1.5e-5`; `-0.0` keeps its sign. Checked against SBCL with `*read-default-float-format*` set to
  `double-float`. (SBCL prints more digits for denormals.)
- Arithmetic: exact operands stay exact; any float operand converts the other
  operand to a double first. **Comparison is exact:** an integer and a float compare as real numbers, so
  `(= 9007199254740993 9007199254740992.0)` is false. `EQL` compares the bits (`0.0` and `-0.0` differ, `1` and
  `1.0` differ); `EQUALP` and `=` treat them as equal.
- `/`: exact operands produce integers or ratios; any float operand gives a float; `(/ x)` is the reciprocal.
- `TRUNCATE`, `FLOOR`, `CEILING` and `ROUND` (nearest, ties to even) return an integer quotient and a
  remainder (exact for exact operands, float when either operand is a float); `REM` and `MOD` take floats.
  Large quotients promote to bignums.
- `FLOAT`, `FLOATP`, `REALP`, `NUMBERP`, `RATIONALP` (integers and ratios), `COERCE` to `FLOAT`/`DOUBLE-FLOAT`/
  `SINGLE-FLOAT`..., `SIGNUM`, `ABS`, `MIN`, `MAX`, `ZEROP`, `PLUSP`, `MINUSP`, `1+`, `1-`.
- `SQRT`, `EXP`, `LOG` (one or two arguments), `SIN`, `COS`, `TAN`, `ASIN`, `ACOS`, `ATAN` (one or two),
  `EXPT` (exact for a rational base and integer power, including negative powers), `ISQRT`. A result that would be complex is an error.
- Constants (immutable since ADR 0056): `PI`, `MOST-POSITIVE-DOUBLE-FLOAT`,
  `MOST-NEGATIVE-DOUBLE-FLOAT`, `LEAST-POSITIVE-DOUBLE-FLOAT`, `DOUBLE-FLOAT-EPSILON`,
  `MOST-POSITIVE-FIXNUM`, `MOST-NEGATIVE-FIXNUM` (the `i64` limits), and `*READ-DEFAULT-FLOAT-FORMAT*`
  (`DOUBLE-FLOAT`, ignored).
- `FORMAT` `~F`, `~E`, `~G` and `~$` follow SBCL: digits come from the shortest representation, rounding to
  fewer digits looks at the next digit and rounds half up (`(format nil "~,2F" 0.125)` is `"0.13"`), `~G`
  appends the exponent-field blanks, an integer argument is converted, any other object prints as `~A`.
  Known differences: a negative `d` for `~F` and SBCL's `~w,d,kF` quirk with a scale factor on tiny values are
  errors or differ.

### Radix integers, bit operations and the Layer 0 control forms (M54, ADR 0045)

`#x`, `#b` and `#o` read integers and ratios (`#x-FF/2`; the sign belongs to the numerator and a zero
denominator is a reader error). `LOGAND`, `LOGIOR`, `LOGXOR` (any number of arguments), `LOGNOT` and
`ASH` work on unbounded signed integers with two's complement semantics, within the exact-number bit limit.
Layer 0 macros (redefinable, absent on the kernel): `PROG1`, `PROG2`, `CASE` and `ECASE` (`EQL` keys; `T` or
`OTHERWISE` only in the last clause), `TYPECASE`, `ETYPECASE`, `IGNORE-ERRORS` (`NIL` and the condition),
and the function `TYPEP`. `TYPEP` knows the atomic types of this image, `OR`, `AND`, `NOT`, `MEMBER`, `EQL`,
`SATISFIES`, `(INTEGER lo hi)` and structure names. `LOAD` restores `*PACKAGE*`.

### `DESTRUCTURING-BIND` and `DEFSTRUCT` (M56, ADR 0045)

`DESTRUCTURING-BIND` is a Layer 0 macro supporting nested lists, a dotted tail, `&OPTIONAL`, `&REST`/`&BODY`,
`&KEY` (including `((keyword name) default supplied-p)` and `&ALLOW-OTHER-KEYS`) and `&AUX`, and since M68 a
leading `&WHOLE` in any pattern and a pattern in place of an `&OPTIONAL` or `&KEY` variable; `&ENVIRONMENT`
is an error. A shape mismatch names the elements and the lambda list. `DEFSTRUCT` is a Layer 0 macro: an instance is the simple vector
`#(RUSTLISP-STRUCT (NAME ANCESTORS...) slot...)` by default (printed `#S(NAME :SLOT value ...)`, which the reader also accepts) (no distinct type, `VECTORP` is true).
Constructors, the predicate, type-checking accessors, `COPY-NAME` and `SETF` of slots are defined;
`:CONC-NAME`, `:CONSTRUCTOR`, `:COPIER`, `:PREDICATE` and `:INCLUDE` are supported. Since ADR 0055,
`(:TYPE LIST)` selects ordinary list storage, and `:NAMED` optionally adds a name marker; details below.
`:PRINT-FUNCTION` and `:PRINT-OBJECT` are ignored on the default representation and rejected with
`:TYPE LIST`; other representation types, offsets and include slot overrides are unsupported.

### `SETF` of the list accessors and `SUBSEQ` (second teaching-subset build)

`FIRST` to `TENTH`, `REST` and the 28 composed accessors `CAAR` ... `CDDDDR` are
`SETF` places (`DEFSETF` in Layer 0): the outermost letter chooses `RPLACA` or
`RPLACD` on the cons the remaining letters reach, and a path that runs off the
list is a type error. `(setf (subseq sequence start [end]) new)` calls `REPLACE`
on a list or vector and returns `new`; the target keeps its length, as in ANSI.
A string target is `NotImplemented` because strings are immutable here, which is
also why `CHAR`, `SCHAR` and `AREF` of a string are not places.

### `LOOP`, symbol functions, property lists, `TRACE` (M62 and M63, ADR 0051 and 0052)

`(loop ...)` whose first element is a symbol is the extended `LOOP`; compound forms only
is the simple loop (needs no prelude). The extended loop supports `named`, `with`,
`for`/`as` (`from`/`upfrom`/`downfrom`, `to`/`upto`/`below`/`downto`/`above`, `by`, `in`,
`on`, `across`, `=`/`then`, `being the hash-keys/hash-values of ... [using ...]`,
destructuring, `of-type` ignored), `repeat`, `while`, `until`, `always`, `never`, `thereis`,
`collect`, `append`, `nconc`, `sum`, `count`, `maximize`, `minimize` (and `-ing`, `into`),
`when`/`if`/`unless` (`and`, `else`, `end`, `it`), `do`, `return`, `initially`, `finally`. A
`for` clause steps sequentially (`and` between clauses is accepted, not parallel); a
`maximize` or `minimize` that never runs gives 0; keywords match by print name. Not
supported: `loop-finish`, `being the symbols/elements`, parallel `for ... and`.
`SYMBOL-VALUE`, `SET`, `BOUNDP`, `MAKUNBOUND` use the dynamic then global value;
`FBOUNDP`, `SYMBOL-FUNCTION`, `FDEFINITION`, `FMAKUNBOUND` use the global operator table
(a protected name is refused). `GET`, `REMPROP`, `SYMBOL-PLIST` keep a list per symbol in a
table the collector traces; `SETF` works on `GET` (two arguments), `SYMBOL-PLIST`,
`SYMBOL-FUNCTION`, `FDEFINITION` and `SYMBOL-VALUE`. `SUBST`, `SUBLIS`, `PAIRLIS`,
`ACONS`, `COPY-TREE`, `UNION`, `INTERSECTION`, `SET-DIFFERENCE`, `SUBSETP` (`:TEST`,
`:TEST-NOT`, `:KEY`; set result order unspecified), `MAPC`, `MAPLIST`. `TRACE` and
`UNTRACE` print `  N: (NAME args)` and `  N: NAME returned v...` on `*STANDARD-OUTPUT*`.

### Memoised macro expansion (M61, ADR 0050)

Evaluating a macro form expands it once and reuses the expansion while nothing
it could depend on has changed. The key is the macro-call cons cell. Defining or
removing any global function or macro, or a `DEFSETF` or `DEFINE-SETF-EXPANDER`
expander, forgets every expansion, so redefinitions take effect on the next
evaluation. A visible `FLET`, `LABELS` or `MACROLET` binding turns the memo off for
that evaluation. `MACROEXPAND` and `MACROEXPAND-1` always run the expander. An
expander with side effects, or one that reads a variable that later changes, is
therefore observed once per form and not on every evaluation, as Common Lisp
allows. Destructive modification of code that has already been evaluated is
undefined, as it was.

### Advisory declarations, `LAST`, `MAKE-LIST`, `TYPE-OF` (M60, ADR 0049)

`IGNORE`, `IGNORABLE`, `DYNAMIC-EXTENT`, `INLINE`, `NOTINLINE`, `TYPE`, `FTYPE` and
`OPTIMIZE` are accepted in a leading `DECLARE` anywhere `SPECIAL` is. Their
shape is checked (`InvalidSyntax` when wrong) and they change nothing.
`DECLARATION` and unknown identifiers stay `NotImplemented`.
`(last list [n])` follows CLHS (a dotted list, `n` of 0). `(make-list n
:initial-element x)` refuses a negative, non-integer or very large `n`.
`(type-of x)` returns a specifier that `TYPEP` accepts: `NULL`, `BOOLEAN`,
`KEYWORD`, `SYMBOL`, `CONS`, `INTEGER`, `DOUBLE-FLOAT`, `CHARACTER`, `STRING`,
`SIMPLE-VECTOR`, `VECTOR`, `HASH-TABLE`, `FUNCTION`, `PACKAGE`, `STREAM`,
`RANDOM-STATE`, a structure or condition class name, else `T`.

### Condition types (M58 and M59, ADR 0047 and ADR 0048)

A tutorial with runnable snippets is in [conditions-tutorial.md](conditions-tutorial.md).

`DEFINE-CONDITION name (parent*) (slot*) option*` is a Layer 0 macro. Slots: `name` or `(name :initarg k ...
:initform form :reader f :accessor f :type t :documentation d)`; options `(:report string-or-function)` and
`(:default-initargs k form ...)`. `MAKE-CONDITION type &rest initargs`. A condition is the vector
`#(RUSTLISP-CONDITION (CLASS ... CONDITION) slot ... report)`; the last element is the report text, computed when
the condition is made (and when a slot is set through a writer).

Standard classes: `CONDITION`, `SERIOUS-CONDITION`, `ERROR`, `WARNING`, `SIMPLE-CONDITION`
(`SIMPLE-CONDITION-FORMAT-CONTROL`, `-ARGUMENTS`), `SIMPLE-ERROR`, `SIMPLE-WARNING`, and, for runtime errors,
`TYPE-ERROR`, `PROGRAM-ERROR`, `ARITHMETIC-ERROR`, `DIVISION-BY-ZERO`, `CELL-ERROR` (`CELL-ERROR-NAME`),
`UNBOUND-VARIABLE`, `UNDEFINED-FUNCTION`, `STREAM-ERROR`, `END-OF-FILE`, `PARSE-ERROR`, `READER-ERROR`. The
evaluator signals the matching `SIMPLE-` subclass (for example `SIMPLE-TYPE-ERROR`), whose format control is
the error text; `DATUM`, `EXPECTED-TYPE`, `OPERATION`, `OPERANDS` and `STREAM` stay `NIL`. `(error "text")` and
`FORMAT` errors are `SIMPLE-ERROR`.

`ERROR` accepts a lone string (taken literally, as always), a condition object, a condition type with
initargs, or a format control with arguments. `SIGNAL` takes the same designators (a string makes a
`SIMPLE-CONDITION`), offers the condition to the handlers and returns `NIL` if none transfers control. `WARN`
signals a `WARNING` inside a `MUFFLE-WARNING` restart and writes an unhandled warning to the process's standard
error; `CERROR` is `ERROR` inside a `CONTINUE` restart returning `NIL` (the continue string is ignored).
`HANDLER-CASE` clauses and `HANDLER-BIND` bindings take a condition type: a symbol, `T`, or `OR`/`AND`/`NOT`
of those; `SATISFIES` and `MEMBER` are `NotImplemented`. A final `(:no-error (variable*) form*)` clause runs
after a normal return with the values bound to its variables. The first matching clause of the innermost
matching handler handles; a handler whose types do not match is passed over. `TYPEP` and `TYPECASE` know the
class names. `PRINC` and `~A` print the report text; `PRIN1` and `~S` print `#<CLASS "report">`. An unhandled
condition ends a program with its report text. Still missing: `RESTART-CASE`, `WITH-SIMPLE-RESTART`,
`FIND-RESTART`, `COMPUTE-RESTARTS`, `ASSERT`, `CHECK-TYPE`, `FILE-ERROR`, the debugger and
`*BREAK-ON-SIGNALS*`.

### Operating-system facilities (M57, ADR 0046)

`(rustlisp-getenv name)`; `(rustlisp-directory-entries path)` giving sorted `(name . :FILE|:DIRECTORY|:OTHER)`
pairs; `(rustlisp-run-program program arguments &key input timeout environment directory)` returning standard
output, the exit status and standard error. No shell is used; a host can deny these facilities (below); failures are `Stream` errors
that `HANDLER-CASE` can catch. `:timeout` bounds the whole call: at the deadline the program is killed if it
is still running, and the call signals its error even when a descendant of the program still holds the output
open (the descendant is not killed). Without `:timeout` the call waits for the program and for end of file on
its output. `(rustlisp-write-bytes path bytes &optional overwrite)` (ADR 0062) writes a
list of integers 0-255 as raw bytes and returns the count; an existing file is refused unless `overwrite` is
non-NIL.

### GCD and LCM (M36)

Both are Layer 0 functions: iterative Euclid over `REM`, with no recursion, no helper function and
no use of `ABS` (a program may redefine `ABS`, `MAX` and so on without breaking them). Every argument
is type-checked, so `(gcd 6 'a)` and `(lcm 0 'a)` are `Type` errors.

* `GCD` works on signed values and takes the magnitude once, at the end; it
  promotes when necessary, including `(gcd -9223372036854775808)`.
* `LCM` first checks every argument and returns zero if any is zero. Otherwise
  it divides by the GCD before multiplying, with bignum promotion as needed.
* At the deepest level of a recursion `GCD` costs 3 evaluator levels and `LCM` 3 (measured; `SECOND`, `THIRD` and `ADJOIN` 1, `INCF` 5 since ADR 0070, 6 before).
* Both agree with an `i128` oracle over all pairs of 16 boundary values (`tests/m36.rs`) and with SBCL
  including results beyond i64.

### Iteration and lists (M36)

* **`DOTIMES`** (Layer 0 macro, `(dotimes (var count-form [result-form]) body...)`). The count form
  is evaluated once, before any iteration, and must be an integer (a `Type` error otherwise, before
  the body runs). The body runs for `var` = 0 .. count-1; a count of 0 or less runs it never. The
  result form (default `NIL`) is evaluated with `var` bound to the count, or to 0 when the count is
  not positive, and its values are the values of the form. An implicit `BLOCK NIL` surrounds the
  whole form, so `RETURN` leaves it (and `RETURN-FROM`, `THROW`, `UNWIND-PROTECT` and errors behave
  as for any body). `var` is bound afresh for every iteration: closures made in the body capture
  separate variables, and assigning `var` in the body does not change the iteration. `GENSYM` names
  the limit and the counter, so the body cannot see or capture them. The counter is compared with
  the count before it is incremented, so it never exceeds the count and the increment cannot
  overflow, even for the largest count (`(dotimes (i 9223372036854775807) ...)` is accepted and
  runs until left). The body costs the same as `DOLIST` and the same as `(loop (return ...))`:
  13 recursive levels at the 80-unit library default (measured, `tests/m36.rs`). Malformed
  specifications are errors before anything is evaluated. Declarations at the start of the body
  are not treated specially.
* **`SECOND` / `THIRD`** (Layer 0): `(car (cdr list))` and `(car (cdr (cdr list)))`. Short lists give
  `NIL`; an atom or a dotted tail is the `Type` error of `CAR`/`CDR`; the element is returned as is.
  They are ordinary redefinable functions and not `SETF`/`INCF` places. M41 adds `FOURTH`
  as the analogous CAR/CDR composition; later ordinal accessors remain absent.
* **`ADJOIN`** (Layer 0): `(adjoin item list &key key test test-not)` for proper lists. It is
  `MEMBER` underneath: the item is looked up with `:KEY`, `:TEST` and `:TEST-NOT` exactly as there,
  with Common Lisp's rule that the **key is applied to the item as well as to the elements**
  (`(adjoin '(a . 1) '((a . 2)) :key #'car)` finds `A`). The default test is `EQL`, so equal strings
  and equal lists are different elements unless `:TEST #'EQUAL` is given. The result is `LIST` itself
  (the identical object) when the item is present, otherwise a fresh cons whose cdr is `LIST`;
  nothing is modified. Any other keyword, `:TEST` together with `:TEST-NOT`, an explicit `NIL`
  `:TEST` and a dotted or circular list (before a match) are errors, never ignored. The key
  function is called once for the item and once per element examined; keyword expressions are
  evaluated once, as in any call. `UNION`, `INTERSECTION` and `SET-DIFFERENCE` are not provided.

## Text streams (M37)

Full reference: [text I/O](text-io.md); decision: [ADR 0025](decisions/0025-text-streams.md).

- **Stream objects.** `HeapObject::Stream`: a buffered UTF-8 text file the object owns, or a host-stream marker.
  Created by `OPEN`; `STREAMP`, `OPEN-STREAM-P`, `INPUT-STREAM-P`, `OUTPUT-STREAM-P` classify them (closed streams
  keep their direction). They print as `#<FILE-STREAM :INPUT "name">` / `#<HOST-STREAM :OUTPUT>`.
- **`OPEN`:** string filenames relative to the process's working directory; `:direction` `:input`/`:output`;
  `:if-exists` `:error` (default) / `:supersede` / `:append` / `:overwrite` / `NIL`; `:if-does-not-exist` `:error` /
  `NIL` / `:create` (output); `:element-type CHARACTER`; `:external-format :utf-8`. Everything else is `NotImplemented`
  before the file system is touched.
- **`CLOSE`:** returns `T`, repeatable, flushes and surfaces a failure (closing regardless); `:abort t` ignores a flush
  failure and does not delete or restore files. Closing a standard stream closes nothing.
- **`READ-LINE`:** `LF`/`CRLF` stripped, second value `T` for a final line without a newline, EOF per `eof-error-p`,
  invalid UTF-8 and lines over 16 MiB are stream errors.
- **`WRITE-LINE`:** `string`, optional stream, `:start`/`:end`; writes `LF`; returns the original string.
- **`WITH-OPEN-FILE`:** Layer 0 macro; closes on normal exit with `CLOSE`, on every other exit with `CLOSE :abort t`.
- **Errors:** `LispError::Stream` (adapted: `ERROR` handlers see it at its origin) for open, close, read, write, closed
  stream and file end-of-file failures; `Type` for non-streams, wrong direction and bad bounds.
- **Command line:** `--script FILE` runs a batch program (no REPL, prompts or printed results; stdin belongs to the program).
  Since M38 the words after `FILE` are the program's arguments (`*COMMAND-LINE-ARGUMENTS*`).

## Text and data processing (M38)

Full reference: [text and data processing](text-data.md); decision: [ADR 0026](decisions/0026-character-io-read-and-script-arguments.md).
Every name below was compared with SBCL where it exists there (`examples/paip/m38-cases.tsv`); the differences are listed in
the reference.

- **Characters:** `CHAR-CODE`/`CHAR-INT`/`CODE-CHAR` (Unicode scalar values; `NIL` for a surrogate or code above 1,114,111),
  `DIGIT-CHAR-P`/`DIGIT-CHAR` (radix 2 to 36, ASCII digits and letters), `ALPHA-CHAR-P`, `ALPHANUMERICP`, `UPPER-CASE-P`,
  `LOWER-CASE-P`, `BOTH-CASE-P` (the single-scalar rule of `CHAR-UPCASE`), `GRAPHIC-CHAR-P` (not a control character); the
  twelve comparisons `CHAR=`...`CHAR-NOT-LESSP` (`CHAR/=` and `CHAR-NOT-EQUAL` over all pairs, the case-insensitive family folds
  to lower case).
- **Strings:** `STRING` (designators), `STRING-UPCASE`/`STRING-DOWNCASE` (`:start`, `:end`), `PRINC-TO-STRING`.
- **`PARSE-INTEGER`:** `(string &key start end radix junk-allowed)` => integer or `NIL`, index. Signed 64-bit; overflow is the
  arithmetic error even with `:junk-allowed`; text that is not an integer is `LispError::Parse` (an `ERROR` condition).
- **Character input:** `READ-CHAR`, `PEEK-CHAR` (peek type `NIL`, `T` or a character), `UNREAD-CHAR` (checked: only the
  character just read, once). One lookahead per input source is shared by `READ-CHAR`, `PEEK-CHAR`, `READ-LINE` and `READ`.
  UTF-8 is decoded without line-ending translation; a bad byte is a stream error after which reading resumes.
- **Output:** `WRITE-CHAR`, `WRITE-STRING` (`:start`/`:end`, `NIL` means the default), `TERPRI`, `FINISH-OUTPUT`/`FORCE-OUTPUT`
  (write buffered text through; failures reported), `PRIN1`, `PRINT` (newline, readable form, space). All take the stream
  designators of M37 and return what Common Lisp specifies.
- **`READ`/`READ-PRESERVING-WHITESPACE`:** one object from any input stream with the ordinary reader; input is fetched a line at
  a time and only until the object has ended; one white-space character after it is consumed (not for the preserving
  form); the rest of the line stays. End of file inside an object is always `IncompleteInput`; since M39 reader errors
  from `READ` and `READ-FROM-STRING` are `ERROR` conditions (a clean end of file on the host input is not), and
  `READ-FROM-STRING` drops one white-space character after its object as `READ` does.
- **`PRINC`** now omits the colon of a keyword (`PRIN1` keeps it). Printed integers, symbols, keywords, strings, characters,
  lists and dotted pairs read back `EQUAL`.
- **Command line:** `*COMMAND-LINE-ARGUMENTS*` (list of strings), `--script FILE ARG...`, `-- ARG...`; a `#!` first line is
  skipped by `LOAD`; a closed output pipe ends a script with 141 (Unix); non-Unicode arguments give status 2.
- **Lists (Layer 0):** `IDENTITY`; `COPY-LIST` (spine copy, dotted tail kept, circular lists diagnosed); `REDUCE` over a list or
  string with `:key`, `:from-end`, `:start`, `:end`, `:initial-value`.

## Text composition (M39, ADR 0027)

Full reference: [text composition](text-composition.md).

- **String streams:** `MAKE-STRING-INPUT-STREAM string &optional start end`, `MAKE-STRING-OUTPUT-STREAM`,
  `GET-OUTPUT-STREAM-STRING`, Layer 0 macros `WITH-OUTPUT-TO-STRING (var)` and `WITH-INPUT-FROM-STRING (var string
  [:start] [:end])`. Every stream operation accepts them; they print as `#<STRING-STREAM :INPUT>` /
  `:OUTPUT` (` closed` after `CLOSE`). Stream errors are catchable `LispError::Stream`; a string output stream holds at most
  256 MiB.
- **`FORMAT`:** destination `NIL` (string), `T` (current `*STANDARD-OUTPUT*`) or an output stream. Directives `~A ~S ~D ~B ~O ~X
  ~R ~C ~% ~& ~~ ~P ~*`, newline, `~{ ~}`, `~[ ~; ~]`, `~( ~)`, `~^` with prefix parameters (`n`, `'c`, `V`, `#`) and `:`/`@`;
  `~R` without a radix writes English or Roman numerals. Errors are `LispError::Format` (catchable); unsupported directives
  are `NotImplemented`. Bounded: parameters 1,000,000, nesting 32, result 64 MiB, loops that use no argument are errors.
- **Sequences and strings:** `SUBSEQ` (lists, strings and, since M40, vectors; proper lists only), `STRING<` `STRING>` `STRING<=` `STRING>=` `STRING/=`
  `STRING-EQUAL` `STRING-LESSP` `STRING-GREATERP` `STRING-NOT-GREATERP` `STRING-NOT-LESSP` `STRING-NOT-EQUAL` with the four
  bound keywords (true results are mismatch indices), `POSITION`, `SEARCH` (since M40 Rust builtins over lists, strings and
  vectors; keys `:key :test :test-not :start :end :from-end` and the `1`/`2` forms), `SORT` and `STABLE-SORT` (the same stable merge sort; **the result is a new list or string and the
  argument is not modified**).
- **Conditions:** reader errors from `READ` and `READ-FROM-STRING` (malformed text, end of file inside an object, end of file
  with `eof-error-p` on a string) are `ERROR` conditions; host end of file and unsupported syntax are not. Keyword-list errors
  became conditions in M40 (see the M40 section below).
  `READ-FROM-STRING` consumes one white-space character after the object unless `:PRESERVE-WHITESPACE` is true.

## Vectors, hash tables and the sequence library (M40, ADR 0028)

Full reference: [vectors, hash tables and the sequence library](data-structures.md).

- **Vectors:** `#(...)` literals (self-evaluating, printed the same way), `VECTOR`, `MAKE-ARRAY` (one dimension; `:initial-element`,
  `:initial-contents`, `:fill-pointer`, `:adjustable`), `AREF`, `SVREF`, `FILL-POINTER`, `VECTOR-PUSH`, `VECTOR-PUSH-EXTEND`,
  `VECTOR-POP`, `ADJUST-ARRAY`, `VECTORP` (true for strings too), `SIMPLE-VECTOR-P`, `ARRAYP`, `ARRAY-TOTAL-SIZE`, `ARRAY-DIMENSION(S)`,
  `ARRAY-RANK`, `ARRAY-HAS-FILL-POINTER-P`, `ADJUSTABLE-ARRAY-P`. At most 16 Mi elements. Multi-dimensional, displaced and specialised
  arrays, bit vectors and `#n(...)` syntax are not supported.
- **Hash tables:** `MAKE-HASH-TABLE` (`:test` `EQ` `EQL` `EQUAL` `EQUALP`), `GETHASH` (value and presence), `REMHASH`, `CLRHASH`, `MAPHASH`
  (insertion order; the function may remove entries), `HASH-TABLE-COUNT`, `HASH-TABLE-TEST`, `HASH-TABLE-P`, `SXHASH`, `EQUALP`.
  `EQUALP` compares a string and a general vector elementwise, so `(equalp "ab" (vector #\A #\b))` is true and an
  `EQUALP` table finds one under the other; `EQUAL` keeps them apart.
- **Sequence library (Rust, lists, strings and vectors):** `FIND`, `POSITION`, `COUNT`, `REMOVE`, `DELETE`, `SUBSTITUTE` and their `-IF` /
  `-IF-NOT` forms, `REMOVE-DUPLICATES`, `DELETE-DUPLICATES`, `REVERSE`, `NREVERSE`, `COPY-SEQ`, `FILL`, `REPLACE`, `SEARCH`, `MISMATCH`, `MAP`,
  `EVERY`, `SOME`, `NOTANY`, `NOTEVERY`, `SUBSEQ`, `LENGTH`, `ELT`, `COERCE`, `CONCATENATE`, `MAKE-STRING`. The sequences are read once into a
  snapshot before any user function runs. `DELETE` does not modify its argument; `NREVERSE`, `FILL` and `REPLACE` modify lists and vectors.
  `SORT` of a vector sorts it in place; `REDUCE` and `SORT` are still Layer 0 Lisp.
- **New `SETF` places** (also for `INCF`, `DECF`, `PUSH`): `AREF`, `SVREF`, `ELT`, `NTH`, `GETHASH` (with its default form), `FILL-POINTER`.
- **Conditions:** unknown, odd or misplaced keyword arguments (builtins and `&KEY` parameters of functions you define), `:TEST` with
  `:TEST-NOT`, and bad `READ-FROM-STRING` bounds are `ERROR` conditions (`Interp::argument_error`). With no handler they are exactly the
  `InvalidSyntax` error they were. Syntax errors in program text are still not conditions.

## M41 application support

See [M41A–E](m41-application-support.md) for the complete string-path filesystem
subsets, explicit source-relative loading, optional bounded host diagnostics,
embedded named-source API and application build schema. Ordinary LOAD remains
working-directory-relative; no ANSI pathname objects, live heap save or evaluator
stack redesign is introduced. File publication is per-file, not transactional
across an EDL/subtitle/report set.

## Interactive development and standard streams (ADR 0054)

`DEFSTRUCT` permits compatible reloads, including changed slot defaults for new
instances. Changing ancestor lists, slot names/order/count or read-only contracts
signals an error before any definition is replaced. Existing instances are not
migrated. This policy does not require detecting existing instances; incompatible
redefinition is rejected even when none remain.

The REPL's fresh prompt is `PACKAGE> ` (initially `CL-USER> `), and continuation
input uses `.. `. An invalid `*PACKAGE*` displays `INVALID-PACKAGE> ` until the
reader reports its error.

The kernel binds all seven standard stream variables. `*STANDARD-INPUT*` and
`*STANDARD-OUTPUT*` initially use host stdin/stdout; `*ERROR-OUTPUT*` and
`*TRACE-OUTPUT*` use host stderr. `*TERMINAL-IO*`, `*QUERY-IO*` and `*DEBUG-IO*`
initially use a bidirectional host marker: host stdin for reading and host stderr
for writing. They do not open a separate controlling terminal. Host markers remain
open after `CLOSE`. Other than `*TERMINAL-IO*`, these variables can be bound and
assigned to redirect their respective facilities. Rebinding or assigning
`*TERMINAL-IO*` is unsupported. `WARN` follows `*ERROR-OUTPUT*`, and `TRACE`
follows `*TRACE-OUTPUT*`; interactive frontend diagnostics follow `*DEBUG-IO*`,
and batch Lisp diagnostics follow `*ERROR-OUTPUT*`.

For ordinary I/O, `T` designates terminal I/O; omitted/`NIL` designates the current
standard input/output. `FORMAT` has its own destination convention: `T` means
standard output, `NIL` returns a string. These rules supersede the earlier
host-only `T` convention. Prompts and printed REPL results still use frontend
stdout. Embeddings may separately capture host error/terminal output with
`capture_error_output` / `take_error_output_string`.

`MAKE-TWO-WAY-STREAM` accepts an open input stream and an open output stream.
The result supports both directions. `TWO-WAY-STREAM-INPUT-STREAM` and
`TWO-WAY-STREAM-OUTPUT-STREAM` return its constituents, also after `CLOSE` of the
wrapper. Closing the wrapper leaves those streams open. All reads share the
input constituent's lookahead; writes and flushing use the output constituent.
File `OPEN :DIRECTION :IO` and synonym streams remain unimplemented.

## List-backed structures (ADR 0055)

```lisp
(defstruct (rule (:type list)) pattern response)
(make-rule :pattern '(a) :response '(b)) ; => ((A) (B))
(defstruct (point (:type list) :named) x y)
(make-point :x 1 :y 2)                 ; => (POINT 1 2)
```

These are ordinary lists: list readers/mutation and sequence functions see the
same storage. Generated readers and SETF writers use the slot's list position;
COPY-NAME copies the spine and shares slot values. Keyword and the existing BOA
constructor subsets are supported. Slot defaults are evaluated only when omitted.
Read-only slots have readers but no SETF expansion.

An unnamed list record has no generated predicate; `(:PREDICATE NIL)` is allowed,
but explicitly requesting a predicate is an error without `:NAMED`. Named list
predicates check the defining symbol at its physical marker position. Neither
kind defines a TYPEP type specifier. TYPE-OF reports the ordinary list type, not
the record name. The empty unnamed record is NIL.

INCLUDE requires another list-backed definition. Its entire representation is
preserved as a prefix, including any marker cells. A named child adds its own
marker after that prefix; parent and child accessors use their recorded indices.
For example, a named parent with one slot and a named child with one extra slot
has `(PARENT parent-slot CHILD child-slot)` storage. Include slot overrides,
`:INITIAL-OFFSET`, and `(:TYPE VECTOR)` remain unsupported.

The reload guard rejects changes to representation, naming layout, ancestors,
slot positions or read-only contracts before replacing any definitions. Compatible
reloads may change defaults without changing existing records. Malformed option
combinations and duplicate slot names are rejected during expansion.

## Early PAIP support (ADR 0056)

Core-layer functions COPY-ALIST and LIST* implement shallow alist copying and
fresh leading conses with a shared arbitrary last argument, respectively.
`(list* x)` is x itself, including an atom; zero arguments is an arity error.
COPY-ALIST copies the spine and each cons entry while sharing entry fields;
non-cons entries are retained. Its outer list must be proper and noncircular.
COMPLEMENT returns a closure which negates only the primary value of its call;
FIFTH is the fifth NTH element, or NIL when the list is shorter.

DEFCONSTANT is a redefinable core-layer macro over a protected primitive. Its
initializer runs in the call-site lexical environment and current dynamic
environment. Only the primary value is stored; successful installation returns
the symbol. Invalid name/documentation syntax fails before the initializer; an
initializer error/transfer does not install anything. Documentation is checked
but not stored. Names already proclaimed special or dynamically bound are
rejected. Repeating an EQL value is accepted; a different value is rejected.
A constant value is not deeply immutable: a list constant still holds ordinary
mutable conses. Assignment, binding and MAKUNBOUND reject constant names. Values
and functions remain separate namespaces. PI and the supplied numeric limits
are now genuine constants at the classic/standard levels.

CONSTANTP recognizes constant symbols (including NIL/T/keywords), self-evaluating
data and a well-formed QUOTE form, returning NIL for other forms without
executing or macroexpanding them. The optional environment argument is ignored;
no environment objects exist. Installing a new constant invalidates memoised
macro expansions. PSETQ's expansion-time constant check includes user constants.

PROGV is a protected kernel special operator. It evaluates the symbol-list form
then the value-list form, validates proper lists and nonconstant symbol names,
and dynamically binds corresponding values while evaluating its body in the
existing lexical scope. Extra values are ignored; missing values establish
**unbound** entries which hide outer/global values. No global SPECIAL
proclamation is added. Ordinary lexical references keep their lexical binding;
SYMBOL-VALUE and EVAL observe the computed dynamic bindings. All final body
values propagate. Bindings restore after normal completion, errors and nonlocal
transfers; UNWIND-PROTECT cleanup still sees them before their contour unwinds.
Input symbol lists are capped by MAX_CALL_ARGUMENTS as a resource safeguard.

MAKUNBOUND now makes the innermost dynamic binding unbound when one exists,
otherwise removes the global value. DEFVAR initializes an unbound PROGV entry
without changing the hidden global. Package reads and prompts do not fall back
to an outer package when the innermost package binding is explicitly unbound.

## Exact-number follow-up (ADR 0058)

`RATIONAL` is a kernel function. Exact inputs are returned unchanged; a finite
float becomes its exact binary rational (`(rational 0.1)` is
`3602879701896397/36028797018963968`). RATIONALIZE remains absent.
INTEGER-LENGTH and LOGCOUNT are core Lisp functions over private limb-scanning
primitives; negative inputs measure/count their complement. LOGBITP and LOGTEST
are core Lisp functions over ASH/LOGAND. LOGBITP accepts any nonnegative integer
index, including one beyond the exact payload bit limit; sign extension handles
that case without allocating a shifted result.

GENSYM accepts bignum suffixes and promotes its counter; a successor exceeding
the exact-number bit cap fails before creating a symbol. Sequence indices accept
nonnegative integers fitting usize; larger integers report an implementation
representability limit. GO/TAGBODY integer tags remain i64, with an explicit
range error before the TAGBODY runs. FORMAT numeric parameters and English/Roman
~R remain i64 with range diagnostics. CODE-CHAR/DIGIT-CHAR return NIL for positive
bignums outside their repertoires.

## Reader syntax, library batch and restarts (M64–M65, ADR 0060)

**Reader.** `#| ... |#` comments nest and an unterminated one is incomplete input. `#+` and `#-`
test a feature expression (a name, or `AND`/`OR`/`NOT`) against `*FEATURES*`, comparing symbols by
name. The initial features are `:COMMON-LISP :RUSTLISP :IEEE-FLOATING-POINT :64-BIT :LITTLE-ENDIAN`
and `:UNIX` or `:WIN32`; no other Lisp's name is claimed. A skipped form is read with
suppression: nothing is interned, packages need not exist, `#.` is not run and unknown `#`
syntax is passed over. `#.form` evaluates `form` while reading, only when `*READ-EVAL*` (initially
`T`) is true; the evaluation runs under the reader's collection inhibition, and a non-local exit
out of it is a `ControlError`. `#S(name :slot value ...)` calls `MAKE-name` on the quoted
values and is governed by `*READ-EVAL*` too. Symbol tokens accept `|...|` and `\` escapes
(`|Foo bar|`, `a\ b`, `||`); an escaped token is never a number and an escaped colon is
not a package marker. The printer writes `|...|` when a name would not read back (lower case,
white space, macro characters, `:`, only dots, number-like, empty). `PRINC` never adds bars.
Still unsupported: `#n=`/`#n#`, `#c`, `#*`, `#p`, `#n(`.

**Printing.** Vector-backed structures print as `#S(NAME :SLOT value ...)` (the slot names are
noted at `DEFSTRUCT` time in the symbol table). Restart objects print as `#<RESTART NAME>`.
`'x` still prints as `(QUOTE X)`. `WRITE` accepts `:stream :escape :readably :base :radix`;
`:pretty :case :level :length :circle :gensym :array :right-margin :lines` are accepted and
ignored. `WRITE-TO-STRING` and `PPRINT` (a newline, then `PRIN1`) exist.

**Library (Classic level, module `library`).** Lists: `ENDP LIST-LENGTH BUTLAST NBUTLAST REVAPPEND NRECONC
LDIFF TAILP TREE-EQUAL MEMBER-IF MEMBER-IF-NOT ASSOC-IF ASSOC-IF-NOT RASSOC RASSOC-IF RASSOC-IF-NOT MAPL
MAPCON SUBST-IF SUBST-IF-NOT SET-EXCLUSIVE-OR SIXTH`..`TENTH CONSTANTLY MERGE MAP-INTO GENTEMP KEYWORDP`;
`SETF` of `SECOND`..`TENTH`. The destructive `N...` variants (`NUNION NINTERSECTION NSET-DIFFERENCE
NSET-EXCLUSIVE-OR NSUBST NSUBLIS NSUBSTITUTE NSUBSTITUTE-IF NSTRING-UPCASE NSTRING-DOWNCASE
NSTRING-CAPITALIZE`) return new structure and destroy nothing, which the standard allows for the
list ones; strings cannot change in place. Strings and characters: `STRING-LEFT-TRIM`,
`STRING-RIGHT-TRIM` (Rust), `STRING-CAPITALIZE`, `CHAR-NAME`, `NAME-CHAR` (the names `Space Newline
Linefeed Tab Page Return Backspace Rubout Null`). Time: `GET-UNIVERSAL-TIME`, `GET-INTERNAL-REAL-TIME`
and `GET-INTERNAL-RUN-TIME` (both microseconds since the first call; `INTERNAL-TIME-UNITS-PER-SECOND`
is `1000000`), `SLEEP`, `DECODE-UNIVERSAL-TIME`, `ENCODE-UNIVERSAL-TIME`, `GET-DECODED-TIME` (time zone
defaults to 0 = UTC; the local zone is never consulted and DST is never in effect), and `TIME`
(reports real time to `*TRACE-OUTPUT*`). Kernel primitives: `RUSTLISP-UNIX-TIME`,
`RUSTLISP-MONOTONIC-MICROSECONDS`, `RUSTLISP-SLEEP`. Compile-time forms as an interpreter sees
them: `THE` (the form), `LOCALLY` (a `LET ()`), `LOAD-TIME-VALUE` (the form, evaluated each time),
`EVAL-WHEN` (the body when `:EXECUTE`/`:LOAD-TOPLEVEL`/`EVAL`/`LOAD` is listed, else `NIL`),
`PROCLAIM` (`SPECIAL` proclaims like `DEFVAR` without a value; other identifiers are ignored)
and `DECLAIM`. `FORMAT ~colnum,colincT` and `~colrel,colinc@T` count columns from the start of the
current line in the output of that call. `PSETF SHIFTF ROTATEF REMF MULTIPLE-VALUE-SETQ` are macros
over `GET-SETF-EXPANSION`. The `IGNORE`/`IGNORABLE`/`INLINE`... declaration identifiers are matched
by name, so a symbol read in `CL` and one read in `CL-USER` both work.

**Restarts (Standard level, ADR 0060).** `RESTART-BIND` accepts `:TEST-FUNCTION :REPORT-FUNCTION
:INTERACTIVE-FUNCTION` (each once, evaluated left to right, each a function). `COMPUTE-RESTARTS`,
`FIND-RESTART`, `RESTART-NAME` and `INVOKE-RESTART` (a name or a restart object) are builtins; a
restart object is the vector `#(RUSTLISP-RESTART name id)`, the same (`EQ`) object for as long as the
restart is established; a stale object is a `ControlError`. A test function receives the condition
argument or `NIL`. `RESTART-CASE` (clauses with `:REPORT`, `:TEST`, `:INTERACTIVE`), `WITH-SIMPLE-RESTART`,
`INVOKE-RESTART-INTERACTIVELY`, `ABORT`, `CONTINUE`, `MUFFLE-WARNING`, `STORE-VALUE`, `USE-VALUE`,
`ASSERT`, `CHECK-TYPE`, `CCASE` and `CTYPECASE` are Lisp. `WITH-CONDITION-RESTARTS` evaluates its
body and does not associate restarts with the condition. `ASSERT` does not prompt for places. Not
supported: a debugger REPL listing restarts after an error, `INVOKE-DEBUGGER`, `RESTART` as a
type, and `*DEBUGGER-HOOK*`.

## Resource limits and sandboxing (ADR 0059, Phase A)

A Rust program that embeds the interpreter sets these through the API below;
the `rustlisp` command and the `rustlisp-mcp` server use the same machinery
(see "Sandboxed command line and MCP server" below). All are off unless the
host sets them.

- `Interp::set_limits(Limits { fuel, max_heap_bytes, deadline })`. **Fuel** is
  one unit per call and per backward jump (a turn of a loop, a `GO` back);
  a builtin is one unit whatever its input size. The two evaluators charge
  different amounts for the same program, so fuel is a bound, not a
  measure. **`max_heap_bytes`** caps an approximate live-heap total that
  counts the contents of strings, vectors, hash tables and string streams;
  an allocation that would reach it collects once and then fails, and a
  payload that grows in place (`VECTOR-PUSH-EXTEND`, `ADJUST-ARRAY`,
  `SETF GETHASH`, writing to a string stream) fails without collecting.
  Under `GcPolicy::Manual` nothing is collected first. The **deadline** is a
  wall-clock instant, checked every 1,024 fuel charges; `SLEEP` and
  `RUSTLISP-SLEEP` never wait past it (a longer wait stops at the deadline
  with the deadline limit). A guest blocked reading input is not
  interrupted.
- A tripped limit is `LispError::ResourceLimit(Fuel | Heap | Deadline)`.
  `HANDLER-CASE`, `HANDLER-BIND` and `IGNORE-ERRORS` cannot catch it, and an
  `UNWIND-PROTECT` cleanup that tries to leave by `THROW`, `RETURN-FROM` or
  `GO` ends with the same error. It latches: every later evaluation fails at
  once until the host calls `Interp::reset_limits` (cleanup forms stop at
  their first call, loop turn or allocation, so cleanup is not guaranteed).
  `Interp::limit_tripped` says which limit tripped.
- `Interp::set_capabilities(Capabilities { files, process, environment,
  load, exit })`. A denied builtin fails before any side effect with
  `"NAME: denied by the sandbox"`, an ordinary error that `HANDLER-CASE`
  can catch. `Interp::sandboxed(limits)` is the standard interpreter with
  nothing allowed and `limits` set.
- With the compiled machine, an endless tail recursion is an endless loop;
  without fuel or a deadline it runs until the process is ended, as an
  endless `LOOP` does in either evaluator. The REPL has no Ctrl-C handler
  (ADR 0001 forbids the unsafe code a signal handler needs).

## Sandboxed command line and MCP server (ADR 0065)

- **`rustlisp --sandbox`** denies files, programs, the environment and `LOAD`
  (a denied call is the catchable `"NAME: denied by the sandbox"` error) and
  allows `QUIT`. `--fuel N`, `--max-heap SIZE` (bytes, or with `K`, `M`, `G`)
  and `--timeout SECONDS` set limits, with or without `--sandbox`; under
  `--sandbox` the defaults are a 10-second timeout and a 256 MB heap, and
  `none` turns a limit off. `--script` and `--load` files load even though the
  program may not `LOAD` further files. A script, or `-e` with its `--load`
  files, has one budget; each REPL form has its own, and the session goes on
  after a limit. A tripped limit ends a script or `-e` with status **3** and
  `resource limit reached: fuel` (or `heap size`, `deadline`) on standard
  error; 1 stays an unhandled error and 2 a usage error. Standard input and
  output stay the process's own.
- **`rustlisp-mcp`** is a Model Context Protocol server over standard input
  and output. Its tools are `eval` (code in, the printed values of the last
  form, the output and any error out; definitions persist between calls),
  `reset`, and, when started with `--root DIR`, `load_file` (a file under
  `DIR`; paths that leave it are refused). The guest has no capability at all,
  including `QUIT`; standard input is always empty; each call has its own fuel
  (`--fuel`, default 100,000,000) and time (`--timeout-ms`, default 5,000) and
  may ask for less; the session has a heap cap (`--max-heap`, default 256M);
  output past `--max-output` (default 64K) per call is dropped and reported.
  A limit stops only that call.
- `RUSTLISP-WRITE-STDERR` (and so `WARN`) writes the host's error output:
  standard error for `rustlisp`, the call's captured output in the server.

## Evaluation by the compiled machine (ADR 0064, ADR 0070)

The compiled machine is the only evaluator: each top-level form is
macroexpanded, compiled once into code objects and run by an instruction loop.
A form it cannot compile is a `NotImplemented` error. `RUSTLISP_EVALUATOR` is
ignored. Compiling a form once, rather than walking it each time it runs,
changes what a program can observe in these ways. They are what ANSI
Common Lisp allows for compiled code and what SBCL does:

- **Proper tail calls.** A call in tail position keeps no frame, so an endless
  tail recursion runs in constant space, like an endless `LOOP`: it never ends
  in `CONTROL-STACK-EXHAUSTED`. Without host fuel or a deadline
  ([Resource limits](#resource-limits-and-sandboxing-adr-0059-phase-a)) it runs
  until the process is ended (Ctrl-C at the REPL ends the process). A
  `--diagnostics` context names only the frames that are still there.
- **Recursion depth.** Compiled recursion is bounded by the machine's frame
  limit (`Interp::set_max_frames`, 100,000 by default), not by the evaluation
  depth limit. The depth limit still counts a call back into compiled code from
  a builtin (`FUNCALL` of a non-compiled function, `MAPCAR`, `EVAL`), compiling a
  deeply nested form, each level of a top-level `PROGN`, and each top-level form,
  because those nest on the native stack.
- **Macros are expanded when a form is compiled.** Redefining a macro does not
  change functions already compiled with the old definition, and a function
  compiled before a macro is defined calls that name as a function. Define a
  macro before the code that uses it, and recompile (reload) users after
  changing it.
- **Whether a binding is special is decided when the form is compiled.** A
  later `DEFVAR` or `DEFPARAMETER` does not make an already compiled binding of
  that name dynamic.
- **Top-level forms are processed one at a time** (ANSI 3.2.3.1). A macro form
  at top level is expanded first, and each subform of a top-level `PROGN` is
  compiled after the one before it has run, so a macro defined by one subform is
  known to the next. A definition inside another form (`LET`, `DEFUN`...) takes
  effect only when it runs, after the whole form was compiled (see
  "Definitions inside another form" above).
- **A compile-time error is raised where the faulty form runs**, not when the
  enclosing form is compiled: a syntax error or a failing macro expander inside a
  function signals when that part of the function runs, and handlers around it
  see it then, once.
- **Order of a call.** A call by name finds its function before evaluating the
  arguments, as the tree walker does, except a builtin that `DEFUN` cannot
  redefine (ADR 0035), which is found after them (it cannot change meanwhile).
- **Fuel.** Host fuel (ADR 0059) is charged per call and per backward jump in
  both evaluators, but they charge different amounts for the same program.

## Macros, printing and generic functions (M67–M71, ADR 0066–0068)

**Declarations (M67).** A type specifier used as a declaration identifier is
the abbreviated `TYPE` declaration (CLHS 3.3.3.1): a standard type name
(`(declare (fixnum x) (string s))`) or a list headed by a standard compound
type name (`(declare ((integer 0 5) n))`). It is checked for shape and ignored.
Structure names are not recognised there.

**Printer control (M67).** The kernel defines `*PRINT-BASE*` (10),
`*PRINT-RADIX*`, `*PRINT-CASE*` (`:UPCASE`), `*PRINT-LENGTH*`,
`*PRINT-LEVEL*`, `*PRINT-CIRCLE*` (`NIL`), `*PRINT-GENSYM*` (`T`) and
`*READ-BASE*` (10), and, for programs that bind them, `*PRINT-PRETTY*`,
`*PRINT-ESCAPE*` and `*PRINT-READABLY*`, which the printer does not read. The
Lisp output functions, `FORMAT`'s `~A` and `~S` and the REPL honour the first
seven: integers and ratios in the base (upper-case digits) with `#b`, `#o`,
`#x`, `#nR` or a trailing `.` under `*PRINT-RADIX*`; the case of a symbol's
upper-case letters (not inside `|...|`); `...` after `*PRINT-LENGTH*` elements
of a list or vector; `#` for a list or vector at `*PRINT-LEVEL*`; `#n=` and
`#n#` for every cons and vector reached twice (shared or circular) under
`*PRINT-CIRCLE*`, a shared tail printed dotted; uninterned symbols without
`#:` when `*PRINT-GENSYM*` is false. A value of the wrong type is a type error
when printing. `~D` and the other numeric directives keep their own base.
Without `*PRINT-CIRCLE*` a cycle still prints with the `...` notation.

**Reader (M67).** `#nR` reads a rational in radix 2 to 36. `#n=` labels the
next object and `#n#` refers to it within one top-level read, so read
structure can be shared or circular (`#1=(a . #1#)`); a reference to an
undefined label and a label defined twice are read errors; inside a backquote
template they stay `NotImplemented`. Under `*READ-BASE*` other than 10 a token
of digits of the base (optionally signed, optionally a ratio) is a number; a
token ending in `.` stays a decimal integer and floats stay decimal.

**Library (M67).** `PRINT-UNREADABLE-OBJECT` (`:TYPE`, `:IDENTITY`; the
identity is a number unique among live objects, not an address);
`Y-OR-N-P` and `YES-OR-NO-P` on `*QUERY-IO*` (the end of the input answers
no); `BOOLE` and the sixteen `BOOLE-` constants (SBCL's numbering);
`LOGEQV`, `LOGNAND`, `LOGNOR`, `LOGANDC1`, `LOGANDC2`, `LOGORC1`, `LOGORC2`;
`FFLOOR`, `FCEILING`, `FTRUNCATE`, `FROUND`; `RATIONALIZE` (the simplest
rational within half a unit in the last place, as SBCL); `SUBTYPEP` for the
type names `TYPEP` knows, structure names and condition classes (a compound
specifier other than an identical one is `NIL NIL`); `SEQUENCE` as a type;
`FUNCTION-LAMBDA-EXPRESSION` (always `NIL T NIL`: no source is kept);
`MACHINE-TYPE`, `SOFTWARE-TYPE` (Rust's architecture and OS names),
`MACHINE-VERSION`, `MACHINE-INSTANCE`, `SOFTWARE-VERSION` (`NIL`);
`USER-HOMEDIR-PATHNAME` (`HOME` or `USERPROFILE`, with a trailing `/`); and
`ENSURE-DIRECTORIES-EXIST` (behind the file capability). `TYPE-ERROR`,
`UNBOUND-VARIABLE`, `UNDEFINED-FUNCTION` and `DIVISION-BY-ZERO` have reports.

**Macro lambda lists (M68, ADR 0066).** `DEFMACRO` and `MACROLET` accept
`&ENVIRONMENT var` (once, anywhere at the top level, but not before `&WHOLE`),
a dotted tail `(a . rest)` (as `&REST rest`), and destructuring patterns
nested to any depth, with `&OPTIONAL`, `&REST`/`&BODY`, `&KEY`, `&AUX` and a
leading `&WHOLE` inside them. A lambda list with a pattern is bound by the
`DESTRUCTURING-BIND` walker, so it needs the classic level (on the core level
it is `NotImplemented`); a call that does not match is an `ERROR` at
expansion time naming the macro, the elements and the lambda list, and the
pattern's defaults run inside the macro's implicit block. `DESCRIBE` shows
the rewritten lambda list of such a macro.

**Environments (M69, ADR 0066).** An expander receives an environment object
(printed `#<ENVIRONMENT>`) for the scope of the macro call, at the top level
too. `MACROEXPAND-1`, `MACROEXPAND` and `MACRO-FUNCTION` take it (omitted or
`NIL` is the null environment) and see the local macros (`MACROLET`) and
symbol macros of that scope; `GET-SETF-EXPANSION` takes one too. In compiled
code the environment does not record a local function that shadows a global
macro. `MACRO-FUNCTION` returns the expander, a function of a form and an
environment, or `NIL`; `SETF` of `MACRO-FUNCTION` (environment `NIL`) installs
a global macro.

**Symbol macros (M69, ADR 0066).** `SYMBOL-MACROLET` is a special operator:
in its body a reference to each name is its expansion, `SETQ` of it is `SETF`
of the expansion (so `INCF`, `PUSH` and the other place macros work), and a
binding of the name (`LET`, a lambda parameter) or a `SPECIAL` declaration
hides it. A name may not be a constant, a proclaimed special variable,
repeated, or declared `SPECIAL` in the body's own declarations (an
`InvalidSyntax` error). `DEFINE-SYMBOL-MACRO` (Layer 0) defines a global
symbol macro, which a lexical binding hides; a special variable cannot be
one. `MACROEXPAND-1` and `MACROEXPAND` expand a symbol macro in their
environment.

**Setf functions (M70, ADR 0067).** `(SETF name)` is a function name for
`DEFUN` (the implicit block is `NAME`), `FUNCTION`/`#'`, `FDEFINITION` (and
its `SETF`), `FBOUNDP` and `FMAKUNBOUND`, but not for `FLET` or `LABELS`. A
protected name cannot have one. `SETF` of a place `(op args...)` whose
operator has no builtin place, macro or `DEFSETF` calls `(SETF op)` with the
new value and the arguments, defined then or later; an undefined one fails
when the `SETF` runs. `(defun (setf foo) ...)` returns a symbol printed
`#:|(SETF FOO)|`.

**Generic functions (M71, ADR 0068).** `DEFGENERIC` (options `:DOCUMENTATION`,
`:METHOD`, `DECLARE`) and `DEFMETHOD` (the `extended` level, where the shipped programs start; `Interp::standard()` does not load it). Methods specialize
required parameters on `T`, built-in classes (`NUMBER`, `REAL`, `RATIONAL`,
`INTEGER`, `FIXNUM`, `BIGNUM`, `RATIO`, `FLOAT`, `DOUBLE-FLOAT`, `CHARACTER`,
`SYMBOL`, `KEYWORD`, `NULL`, `LIST`, `CONS`, `SEQUENCE`, `ARRAY`, `VECTOR`,
`SIMPLE-VECTOR`, `STRING`, `FUNCTION`, `HASH-TABLE`, `PACKAGE`, `STREAM`,
`RANDOM-STATE`, `STRUCTURE-OBJECT`), structure names, condition classes and
`(EQL form)` (evaluated when `DEFMETHOD` runs); dispatch is on every required
argument. The standard method combination: `:AROUND`, `:BEFORE`, primary and
`:AFTER` methods; `CALL-NEXT-METHOD` (with or without new arguments) and
`NEXT-METHOD-P` in primary and around methods; a method body is in a block
named after the generic function. A method with the same qualifiers and
specializers replaces the earlier one. Errors: no applicable method, no next
method, a lambda list with a different number of required parameters, an
unknown class, a name that is already an ordinary function or macro, a
qualifier other than the three. `DEFMETHOD` and `DEFGENERIC` return the
generic function, an ordinary function object. Under the tree walker at the
library's default depth limit (80) a long `CALL-NEXT-METHOD` chain or a
`PRINT-OBJECT` method can exhaust the depth; the machine and deep mode (the
shipped programs) are not affected.

**PRINT-OBJECT (M71, ADR 0068).** A `PRINT-OBJECT` method on a structure
or condition class is used by `PRIN1`, `PRINT`, `PRINC`, `WRITE`,
`PRIN1-TO-STRING`, `PRINC-TO-STRING`, `FORMAT` (`~A`, `~S`), the REPL and
`Interp::eval_to_string`, wherever the object appears in what is printed, with
`*PRINT-ESCAPE*` true for the readable form and false for the aesthetic one.
The default method prints as before, so `CALL-NEXT-METHOD` gives the usual
`#S(...)`. Methods on built-in classes are not used by the printer. A
`DEFSTRUCT` `:PRINT-FUNCTION` (called with depth 0) or `:PRINT-OBJECT` option
with a function becomes such a method at the extended level.


**Internal helpers (ADR 0069).** Only the `RUSTLISP-` names of manual chapter
8 are external in `COMMON-LISP`. The helpers the standard macros expand into
are internal there: a program's own `RUSTLISP-DB-BIND` is a different symbol
and cannot break `DESTRUCTURING-BIND`; a helper is reachable only as
`CL::RUSTLISP-...` (unsupported). The code the implementation builds
(macro wrappers, backquote, `#'`, place store forms, destructuring macros)
names `COMMON-LISP` symbols whatever the current package, so these work in a
package that does not use `COMMON-LISP`.

## Interactive embedding sessions (ADR 0071)

A Rust host may attach a session and run `eval_session` on its own worker thread.
Input arrives through a bounded UTF-8 queue: empty waits, closed and drained
means EOF. READ, READ-LINE and character operations share the existing lookahead.
A cancelled partial read can consume input; cancellation is not transactional.

Output becomes visible to a separate control handle before evaluation finishes.
Host output and error output share a bounded transcript, truncated at UTF-8
character boundaries without raising a Lisp error. Draining does not replenish
the per-evaluation output allowance. Lisp streams redirected to a file or string
retain their usual behavior and do not enter that transcript.

Stop targets the active evaluation identity and produces host-only
`ResourceLimit(Cancelled)`. Cleanup is not guaranteed after a resource limit;
HANDLER-CASE and HANDLER-BIND cannot catch it. Queued input waits and session
SLEEP are interruptible and deadline-aware. Native stdin/file reads and long
builtins are not preempted. A fresh session evaluation clears the latch and sets
fresh limits; ordinary evaluation APIs still require explicit reset after a trip.
Returned values are read-only printed strings, without PRINT-OBJECT invocation.
No filesystem jail, native stack enlargement or C/Swift ABI is supplied here.

## Host filesystem restriction

An optional host root (ADR 0072) restricts path operations, including host
`load_file`, to an app-owned directory. Relative paths become root-relative;
explicit source-relative loads retain their meaning. Capabilities still apply.
Policy denials are recoverable Stream errors, raised before modifications. No
root retains existing behavior. This is not race-resistant OS confinement and
does not revoke streams or confine subprocesses. See
[filesystem policy](filesystem-policy.md).
