Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.

src/snapshot.x

Deterministic compiler symbol snapshot I/O.

Functions

FunctionSummary
snapshot_write_varWrites one value in the snapshot’s restricted Lisp grammar.
symbol_snapshot_loadLoads exactly one version-3 symbol snapshot from path.
symbol_snapshot_writeWrites a deterministic version-3 symbol snapshot to output.

Functions

snapshot_write_var

int snapshot_write_var(File output, Var value)

Writes one value in the snapshot’s restricted Lisp grammar. Lists are written recursively. A Symbol that requires quoting or an unsupported value returns zero; otherwise the result is one. A successful result establishes representability, not stream health, so the caller must inspect output.error() separately. The stream remains open.

Source: src/snapshot.x:25

symbol_snapshot_load

Map symbol_snapshot_load(String path, Map *fn_defs, int *gensym)

Loads exactly one version-3 symbol snapshot from path. Returns a Scope-owned symbol Map. On success, optional fn_defs receives a Scope-owned Map of rows marked definition, and optional gensym receives the greatest nonnegative (gensym N) identifier found recursively. After the file and bare Lisp session are constructed, every read and validation path releases both.

Raises: <not-found> or <io-fail> while reading, <incomplete> for a truncated Lisp form, or <malformed> for invalid Lisp syntax, an invalid snapshot shape, or trailing input.

Source: src/snapshot.x:119

symbol_snapshot_write

int symbol_snapshot_write(Map symbols, Map fn_defs, File output)

Writes a deterministic version-3 symbol snapshot to output. Rows are sorted before emission. Function rows whose spelling occurs in fn_defs carry a definition marker. Returns zero for an unrepresentable value or stream error and one on success; failure may leave partial output. The input Maps are unchanged and the stream remains open.

Source: src/snapshot.x:72

Design notes

Serializes the compiler’s invariant runtime symbol Map as Lisp data and restores it through the shared Lisp reader. Source-specific declarations overlay the restored Map in the ordinary shallow-parse path. Writing sorts entries before emitting the versioned artifact; loading validates the complete reader shape before publishing a Map.