plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
8f82f28
— Peter John
2026-11-16T14:22:57+05:30
docs/plans: the modular checker's design and stages
docs/plans/2026-11-16-modular-checker.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Modular checker (design, 2026-11-16)
|
|
2
|
+
|
|
3
|
+
User: "Yes I want a modular checker". Design by a read-only agent over simpler-language after c086b705 (parse cache). Build after the rules task and the benchmark.
|
|
4
|
+
|
|
5
|
+
Measured (debug, loaded machine): `plum check` of a small example spends ~40-50 ms re-checking std (std's floor); Map's tests: check 0.17 s wall (load ~90 ms, check 116 ms in two passes because of `for` lowering); `plum test` of it 1.55 s: first check 116 ms, dead code 64, closure spec 60, fusion 99, in place 193 (uniqueness 133), trmc 53, five whole-program re-checks of 41-48 ms each, ~0.85 s codegen + wasmtime.
|
|
6
|
+
|
|
7
|
+
Correction: `resolveModules` renames clashing enum variants, not functions; importer-dependence comes from the variant clash rule (entry keeps the name) and `shadowStdTypes` (std's type renamed `PairStd`, std text re-parsed).
|
|
8
|
+
|
|
9
|
+
Design:
|
|
10
|
+
1. ModuleArtifact = interface (types after the front end, traits incl. default bodies, statics' signatures, consts, canonical names; hashed) + body results (lowered AST, types of non-generic fns, root call sites, dispatch demands, diagnostics). Generic bodies checked erased in the module; per-instantiation checking moves to a per-program link step (memoisable for std-only type args).
|
|
11
|
+
2. Names: canonical names fixed by the defining module; the dependency keeps its name, the dependent renames (`Name@module`), replacing `shadowStdTypes` and the entry-keeps rule; per-owner loop/upcast counters.
|
|
12
|
+
3. Node ids: module-local ids, rebased into a contiguous block at link; codegen unchanged; merge order kept (name section).
|
|
13
|
+
4. Link: merge per-module Traits, expand dispatch demands, run the instantiation worklist, sort errors, build TypedInfo.
|
|
14
|
+
5. Cache: memory per run + disk (parse_cache's dir/handling), key = file text + sorted (path, interface hash) of the transitive closure + compiler id + options; body edits don't invalidate importers; `PLUM_CACHE_VERIFY=1`.
|
|
15
|
+
|
|
16
|
+
Stages (each keeps test-all green; wasm compared against a Stage 0 baseline hash of the whole sweep):
|
|
17
|
+
0 baseline harness (S); 1 importer-independent names (M); 2 per-module front end (L); 3 module check + link, no cache (XL); 4 in-memory cache (S-M); 5 disk cache (M); 6 instantiation memo (M); 7 optional: incremental re-check in the passes (reuse per-function results for functions a pass left unchanged) and/or a parametric fast path for generics.
|
|
18
|
+
|
|
19
|
+
Expected: `plum check` one file ~35-45% off; `plum check std tests` ~40-60% off; LSP the biggest win; `plum test` one file only ~6-8% (the five re-checks, uniqueness, codegen and wasmtime dominate); test sweep ~10% without Stage 7; Stage 7 up to another ~10-15%.
|