plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


20de20e — Peter John 2026-11-11T01:47:11+05:30
Backlog: rewritten, open items only
Files changed (1) hide show
  1. docs/backlog.md +60 -95
docs/backlog.md CHANGED
@@ -1,97 +1,62 @@
1
1
  # Backlog
2
2
 
3
- Open work, in the order the user queued it, plus smaller items found during builds. Each item links where it came from. Decisions behind these are in `docs/decisions/2026-11-language-and-scene-decisions.md`.
4
-
5
- ## Planned (in order)
6
-
7
- **Current order (user 2026-11-05):** explicit fn generics (done faa4d7e) → cleanup phase 3b (pass list, positioned errors; running) → Io primitive + extern methods → move Rust crates under `compiler/` → tooling + scripts moved under compiler/ (done) → cleanup phase 4 (done: node ids, typed codegen, `inferExpr` errors at spans; `docs/plans/2026-11-05-compiler-cleanup-phase4.results.md`) → phases 5 and 6 (done: file splits, type kinds, tests in Plum; `docs/plans/2026-11-05-compiler-cleanup-phase5-6.results.md`) → game engine refactor (done) → FBIP stage 1 (done: switch, proof, `Array.with`, `fip fun`, pilot; `docs/plans/2026-11-06-fbip-stage1.results.md`) → a simpler language, then the rest of FBIP (`docs/plans/2026-11-06-simpler-language.review.md`, needs the user's decisions) → benchmark (incl. iterator unboxing / niche Option, run C game A/B) → deterministic sim → kids' games. The items below keep their detail; this line wins on order.
8
-
9
- 1. **Compiler cleanup and architecture** — `docs/plans/2026-11-04-compiler-cleanup.review.md` (written in another session; meant to run after language-restrictions merged). Approved 2026-11-04; running on branch `superlite/compiler-cleanup`, phase 1 first.
10
- - **Explicit function generics** (user 2026-11-04: right after cleanup phase 2) — functions declare their generics (`fun map[B](...)`) instead of every single capital letter being a generic; allows longer generic names and one-letter concrete types/tags. Grammar change + about 140 signatures in std/examples. Phase 2's "generics by scope" makes this mostly a grammar + signature rewrite.
11
- - **Io as a built-in primitive with extern methods** (user 2026-11-04: LAST, once the whole compiler refactor and explicit generics are done) — `docs/plans/2026-11-04-io-primitive-extern-methods.review.md`. `primitive Io` with `extern fun f(self, ..)` methods replaces the ~55 top-level externs + forwarding `record Io` methods. A fake/recording `Io` comes later via a trait or language mocks.
12
- 2. **Simplify the language: no traits, no union enums, native inline variants** (decided by the user 2026-11-04; runs right after compiler-cleanup phase 3a, before explicit generics and 3b; decision record §13). Traits are removed as a language feature and replaced by records embedding records with subtyping + `override` dispatch (a `Ship` embedding `Node` is accepted wherever a `Node` is, and calls dispatch to Ship's overrides — the scene graph's `trait Actor` becomes a base record). Union enums (`enum X = A | B` of records) are removed: `JsonParse` and the union examples become inline-variant enums, union syntax becomes an error. Inline variants compile natively as struct subtypes of their enum, deleting `hoistInlineVariants`, the `List__Cons(Cons(..))` wrappers, union forwarders, `union_lower` and the checker's union plan. `unboxed_variants.plum` is a compiler probe: move it to a codegen test. Same plan also covers (user 2026-11-04): `=` reassign-only, no generators (`fun*`/`yield`; Seq deleted, one loop form `for x := range v` over Int or any `next(self) -> Option[Pair[T, Self]]`), no variadics (`...T`; `[..]` literal → `Cons`/`Nil`, `[k => v]` → `Map.empty().with(..)`), no value enums, `record` merged into `struct` now, and **run D: error sets / `T!E` / `T?` / `null` replaced by std `Option[T]` and `Result[T, E]` enums**, with postfix `?` as the ONLY sugar (revised 2026-11-05: `try`, `?:`, `?.`, `catch`, `T?`, `E!T`, `null` all removed; runs right after run C; decision record §13 item 1). Runs A (in progress), B (struct), C (traits/unions), D (Option/Result).
13
- 3. **Benchmark** before FBIP (user: FBIP waits for it).
14
- - **Unbox iterators / niche Option layout** (user 2026-11-05: later, here, not before generics). Run D made `for` loops slower: for-over-List 1M 28 → 49 ms (+75%), for-over-Range 6 → 8 ms (+33%), Map.get +17% (docs/plans/2026-11-05-language-simplification-d.benchmark.md). Cause: `next() -> Option[Pair[T, Self]]` allocates a `Some` cell per step on top of the Pair (the old `Pair?` was a nullable ref). Options: `Option[R]` for a GC ref R as a nullable ref (niche), and/or fusion/drive unboxing the `Some(step) := it.next()` loop. Bisect 961bd21 vs d7658cc back-to-back first.
15
- - **Run C game A/B** still owed (stress_scene/stress_world vs pre-run-C). D2 found closure-spec hints were empty since run C (fixed), which may explain part of it.
16
- - **Build-speed** done separately right after run D (2026-11-05).
17
- 4. **FBIP: no heap mutation** — persistent std collections updated in place when unique, Koka-style `fip` functions as a checked in-place guarantee, a reference count used only as a uniqueness check if static proof falls short. Worklist = the `mut` fields left today (see below). (Decision record §9.) User 2026-11-05: FBIP sits behind a flag like fusion (a `PassOptions` switch / `--no-fbip`), so it can be turned off and A/B'd.
18
- 5. **One product type, `struct`** — after FBIP, merge `record` into an immutable `struct` with compiler-chosen boxing (optional hint, shown by `--explain`). (Decision record §9b.)
19
- - **Decide: do we still need traits?** (user 2026-11-04, decide with this item and item 2, since traits are lowered through the same hidden-union machinery). Today traits are used only by `std/game/imperative/Scene` (`trait Actor`, 14 fields), `std/game/pure/PureScene` (field-less `trait Actor` for `Custom` nodes) and three examples. The functional scene, the kids' games plan and `../kam_plum` use none. Their unique job is letting std hold user-defined kinds (a scene tree of the game's own `Ship`/`Orb`) with static dispatch.
20
- - **User's proposal:** make `Actor` a plain struct/record and let embedding give inheritance-like behaviour: a record that embeds another *first* is a subtype of it (`Walker` is an `Actor`, so it can sit in a `Slice[Actor]`), with `override fun` dispatched on the concrete kind. Today record embedding only copies (`a World is not a Stage`), so this means embedding becomes subtyping. That is the box-free trait layout (wasm-gc base struct + subtypes, `isSubtypedTrait`) applied to records, which would retire trait fields, `__get_`/`__set_` accessors and the boxed-trait path. Open: whether behaviour-only traits stay (Rust-style, no fields) or abstract methods on the base record cover them; what `==` means on a subtyped value (identity today); whether only first-position embedding subtypes (the rule today).
21
- - **Performance evidence** (BENCHMARK.md, 2026-11-03 benchmarks, M3 Pro headed): at 5.8k nodes the three styles are within about 3% (imperative trait Scene 1.70 ms, pure 1.71, functional 1.75, draw-dominated). Boxed trait field reads from outside the trait cost a dispatch over every actor kind (about 30-40 ns vs 10 ns), which made `stress_world` (20k nodes, y-sort) +92%; the box-free subtyped layout brought it back to closure speed (1.10 vs 1.09 ms). So the proposal keeps the fast path. Method dispatch is still a `ref.test` chain whose cost grows with the number of kinds. Not measured: a functional-style 20k-node world (no culling or sort fixture exists for it) and per-frame allocation/GC of `State` at that size. Add a `stress_world_state_view` fixture to the benchmark item (3) before deciding.
22
- 6. **Deterministic games** — fixed timestep, input recording and replay, seeded `Random` in game state, state checksums; port the design from `../kam_macroquad` (`main.rs` tick accumulator, `game/replay.rs`). The `Io` capability makes recording and replaying host input straightforward. (Decision record §10.)
23
- - **Design notes (2026-11-05):** determinism comes from what may enter `update`, not from the style. Rules for both styles: (1) fixed timestep — host accumulates wall time, calls `update` with a constant `dt`, `draw` may interpolate; (2) input is a per-tick `InputFrame` value passed in, never polled inside `update` (a replay is the list of frames); (3) `update` takes no `Io` — the compiler then proves it reads no clock/random/files and draws nothing; `draw(state, io)` keeps `Io` and can't change state; (4) a seeded `Random` lives in the state (each draw returns a new generator); seed from `io` once at startup, recorded with the replay; (5) no ordering by reference identity or host-seeded hashes (std Map's hash is deterministic; keep it so); (6) wasm floats are deterministic IEEE 754 (don't hash NaN bits); (7) hash the state after each tick, compare runs.
24
- - **Imperative** (`update(world, input)` mutates): deterministic under the rules, but snapshots/rollback need a deep copy or serialization of the mutable graph, checksums need a graph walker that skips shared refs, and mutation order through aliases is part of the semantics (fragile).
25
- - **Functional** (`update(state, input) -> State`): determinism is almost free — pure by construction (purity pass can check it since `update` has no `Io`); a snapshot is keeping the old value (persistent structures share memory), rollback/resimulation = old state + logged inputs, checksum = hash of a value. Cost: a new state per tick, which FBIP removes when the old value isn't shared. Argues for the functional shape when the game styles become one (see "One way to build a game").
26
- 7. **Kids' games (ages 4-7)** (user 2026-11-04: LAST, after all the refactoring is done) — review plan `docs/plans/2026-11-04-kids-games.review.md` (written, NOT approved; re-present for a fresh human approve). Seven functional-style games in `examples/games/functional/kids/`: Balloon Pop (tap), Bunny Hop, Letter Bubbles, Caterpillar, Color Piano, Star Rocket (gentle Orb Run), Hoppy Frog (platformer); nothing can be lost. Draft `balloon_pop.plum` exists (untracked) and is blocked by the `List.length` bug below. Re-check the plan against the post-refactor APIs (explicit generics, `Io` primitive, crate paths) before approving.
27
-
28
- ## Planned, not yet placed in the queue
29
-
30
- - **Generics in `<>`, traits in `[]`** (user 2026-11-09, later; form DECIDED 2026-11-10: `struct Ship<M>[Actor<M>, Clickable](x: Float, y: Float)`, over `struct Ship[M](Actor[M], Clickable)(..)` and over keeping `is`; built as wave 1 of `docs/plans/2026-11-09-comptime-generics.review.md`): `struct Ship<M>[Actor<M>, Clickable](x: Float, y: Float)`, `fun map<B>(..) -> Option<B>`, `Slice<Jv>()`, `stage.updateAs<Orb>(id, f)`; replaces `[]` generics and the `is` clause. In expressions `<` is also less-than: parse `name<...>` as type arguments only when the matching `>` is directly followed by `(`, `.` or `)` (C#/Kotlin rule; `a < B > (c)` would compare a Bool), and split `>>` in nested types. Mechanical but touches every generic in std, examples, tests, docs, the parser, tree-sitter and type-printing snapshots; do it as one task. An intermediate option discussed: `struct Ship(Actor, Clickable)(x: Float, y: Float)` with `[]` generics kept.
31
- - **Optional or automatic actor keys** (user 2026-11-09, after the actor-trait plan). Store does not replace `key`: the Store holds game state, while `key` names one actor in the tree for `Kill(id)`, `updateAs[T](id, f)`, `findAs[T](id)` and messages like `Collected(id)`. Most actors don't need one: self-removal uses `gone`, messages can carry data (`Collected(points: 10)`), and singletons can be found by type (`findAs[Player]()`). Options: (a) make `key` a default method `fun key(self) -> Option[Int] = None`, overridden only by actors a rule must pick out; (b) have the tree hand out ids itself: a counter in `SceneTree`, the id stored in the tree node next to the actor (not in the actor), given on `Spawn`, and returned by queries such as `findAll[Orb]() -> List[Pair[Int, Orb]]`. Use a counter, not a random id: it is unique, needs no `Random` and keeps replays deterministic. Not an index or path in the tree, which changes after a kill. Open: how a spawner learns its child's id (maybe `Spawn(actor, onId: fn(Int) -> M)`).
32
- - **Faster SceneTree step, staying functional** (user 2026-11-09: backlog it; bring it up only if the master vs simpler-language benchmark is really bad). No mutation in the language: better data structures, caching and FBIP. Today `stepChain` (std/game/scene/SceneTree.plum) rebuilds an `FRoseNode` per live actor per step, recurses down `nextSibling` (10k-deep for 10k siblings), and makes 3–5 trait dispatches per actor (`gone` before and after `step`, `key`, `place`, `opacity`). In order:
33
- 1. **Keep unchanged nodes:** tried 2026-11-09; the mechanism landed, the step walk kept its rebuild. std's `ref.same(a, b)` (std/ref.plum: one `ref.eq`; the checker allows heap types only; a variable passed to it is never updated in place, `plum_core::uniqueness`) now keeps unchanged nodes in `inputChain`, `withRoot` and Game's `liveAt`, `shown`, `spliced`, `replaceKid` and `onScreen` (a `react` that returns its tree, as for every `Tick`, leaves the game's tree as it was). In `stepChain` and `applyChain` it was slower, also on the new "mostly still" workloads 10 and 11 of benchmarks/scene_trees (10,000 actors, 1% moving: 148 ms rebuilding vs 240 ms sharing): keeping a node needs its later siblings' result before it is built, so the walk recurses along each sibling chain, and that loses the compiler's tail-modulo-cons loop, which builds a chain front to back without recursion. In a left-child right-sibling chain only a suffix after the last changed sibling could be kept anyway. Sharing in the step needs item 3 first (a chunked children vector, where a still chunk is kept whole), or a codegen loop that defers the copy of an unchanged run of siblings and links the old run at the end. The cached per-node "subtree can change" flag (skip still subtrees whole, like Flutter `const` or React `memo`) is not done: a node needs a field `FRoseTree` doesn't have, an actor needs a way to say its `step` is the default (returning `self` is not enough, `step` may push commands), and a `Spawn`/`Kill` batch into a still subtree must still walk it.
34
- 2. **Fewer dispatches:** drop the pre-step `gone()` check (`apply` filters actors spawned gone); later maybe `key`/`place` as fields.
35
- 3. **Chunked persistent vector for children** (32-way trie, wasm-gc array leaves, Clojure/Scala style) instead of the cons chain: about 32 times fewer spine allocations on a full map, a loop instead of deep recursion, log₃₂ n path copy for `updateAs`.
36
- 4. **FBIP into the tree:** a binder taken out of a uniquely owned value by a consuming match is unique too (Koka Perceus-style reuse, done at compile time), so `stepChain` rebuilds nodes and actors in place; kept snapshots still copy.
37
- 5. **Cache derived data:** per-node world transform recomputed only when a `place` above it changed; reuse last frame's draw list when the root is the same reference; a spatial grid for hit tests rebuilt only when nodes moved.
38
- - **Testing improvements** (user 2026-11-06, "All 3 please", and "Yes please add group"):
39
- - **`group "name"` blocks:** a naming and scope block with one level of nesting. It can hold helper functions and constants visible only inside it, stripped from normal builds. No `setUp` or `tearDown`, and no test classes. After T10 of the simpler language run.
40
- - **One test command:** runs every Rust test executable plus the sweep. Comes right after the current fix in the simpler language run.
41
- - **Compare-mode tests:** one test flag that runs a test with and without fusion and FBIP. After T10 of the simpler language run.
42
- - **Property tests in `std`:** `check(|a, b| a + b == b + a)` with generated inputs. After T10 of the simpler language run.
43
- - **Language ideas to discuss later** (user 2026-11-05: "add them ideas to be discussed later"):
44
- - **Single inheritance** — DECIDED 2026-11-05, built in run C (T11).
45
- - **One way to build a game** (user 2026-11-05, idea): collapse the three styles (std/game/imperative Scene, functional FunctionalScene/Ui, pure PureScene/SceneInput) into one; the game-entry shape (below) is chosen with it.
46
- - **Sprite animation + state machines** (2026-11-05 notes): playback is a function of time, so the functional sprite stores only `clip` + `startedAt` and computes the frame in `draw` (`(tick - startedAt) / ticksPerFrame % frames`) — no per-tick mutation, no drift, free under replay/rewind; std's `game/functional/Anim.plum` already works this way ("animations as pure functions of time"). The imperative sprite mutates `frame`/`timer` and must be advanced exactly once per tick per sprite. State machines (idle/run/jump/land) are an enum with per-state data (`Jump(since, vy)`) and a `step(pose, input, tick) -> Pose` match — exhaustive and type-checked; the clip follows from the pose, `since` doubles as the clip start. Imperative tends to `mut state: Int` + loose fields valid only in some states. Real functional costs: deep nested updates (rebuild the path; `T(..x, f: v)` spread helps, maybe lens sugar later; FBIP removes the allocation) and events returned as data (`step` returns pose + `[SpawnHitbox(..)]`, the world applies them) instead of mutating callbacks — more explicit, and what makes it replayable.
47
- - **No top-level functions** (user 2026-11-05, thinking, not scheduled): every `fun` lives under a `primitive`, `enum` or `struct`; this also removes top-level `extern fun` (Io's host calls are already `extern` methods on `primitive Io`). The entry point is always on `primitive App` (`primitive App = fun main(io: Io)`). Games (user 2026-11-05, preferred): std `struct Game = abstract fun update(self, io: Io, dt: Float) -> Game; abstract fun draw(self, io: Io)`; the game's `World` embeds `Game` and overrides both; `App.main(io) = io.run(World(..))`. `io.run` hands the game ref to the host (rooted); each frame the host calls two codegen-generated exports that dispatch `game.update`/`game.draw` (normal override dispatch); `update` returns the next `Game` (imperative returns `self`, functional/pure a new value), the host keeps it. A missing `draw` is a compile error (abstract), no magic export names, "init" is just constructing `World` in `main`. Replaces the three free `export fun init/update/draw`. Considered: `App.init/update/draw` statics (untyped name contract). Open (user: "this is more OOP"): the functional alternative `io.run[S](state: S, update: fn(S, Io, Float) -> S, draw: fn(S, Io))`, e.g. `App.main(io) = io.run(World.start(io), World.update, World.draw)` — typed by the call, no base class, state-in/state-out (FBIP, deterministic sim); host stores state + two fn refs. Undecided (user 2026-11-05): pick when the three game styles (imperative, functional, pure scene) are collapsed into ONE way to build a game; the game-entry shape is chosen together with that. Trade-offs noted: embed `Game` uses the struct's single embed slot and makes `update` return the base `Game`; `io.run(state, update, draw)` keeps the concrete type and lets tests swap `update`. Open points: unqualified calls inside a type resolve to its own statics (so helpers stay short at call sites); loose helpers go in a `primitive Name =` namespace (exists today); `test` blocks stay top-level. Scale: ~109 top-level fns in std, ~350 in examples, ~70 in web-test fixtures.
48
- - **One way to set up a struct.** Drop `fun init(self)` in favour of field defaults + ordinary constructor functions. `init` is what forces the Boxed layout and the EmbedInit machinery in `ctors.rs`. Main user: `std/game/imperative/Scene.plum`.
49
- - **From Pony:** (1) a two-level ownership model (unique + mutable vs shared + immutable, like Pony's `iso`/`val` with `consume`) as the visible face of FBIP, replacing `mut` fields — take into the FBIP plan; (2) no ambient authority: no globals, a function without `Io` provably does no IO — what deterministic sim needs; (3) Pony partial functions (`?`, no error value) argue for `Option` + `?` as the common path and `Result` only when the error value matters. Not copied: union types, structural interfaces, six capabilities.
50
-
51
- - **Self-hosting groundwork** (user 2026-11-04: plan now, build later) — `docs/plans/2026-11-04-self-hosting-groundwork.review.md`, design in `docs/plans/self-hosting.md`. All host I/O onto `Io` (`os.plum` deleted, `io.now()`, `io.httpGet`), then a Plum lexer, a winnow-style combinator library with chumsky-style errors, an AST and a parser in `compiler/` that parses every `.plum` file. AST comparison with the Rust parser and new host calls (args, exit, env, stderr, binary files) wait for cleanup phase 2a. The `Io` move should land before the `Io`-primitive plan above.
52
-
53
- ## FBIP worklist: `mut` fields left after language-restrictions
54
-
55
- | Type | `mut` fields | Why it is mutable today |
56
- |---|---|---|
57
- | `Slice` | data, start, size, cap | grows in place (push, removeAt) |
58
- | `Buffer` | data, len | in-place byte buffer |
59
- | `Map` | index, hashes, keys, vals, alive, used, size | open-addressing table |
60
- | `Deque` | buf, head, size | ring buffer |
61
- | `JsonParser` | pos, text | parse cursor |
62
- | `Action` (std/game/pure) | elapsed, current | animations stepped in place; a pure version needs a `stepAll` redesign |
63
- | imperative `Actor` trait, `Stage`, `Text.text` | all / camera / text | the mutable scene, by design |
64
- | game shells (`World` etc. in examples) | state, wasDown, … | host shell state |
65
- | `Ship`, `Orb`, `Mine`, `Star` (games/pure) | clock, vx, vy | actor state changed in `act` |
66
-
67
- ## Smaller open items
68
-
69
- - **Go-to-definition in the LSP is gone** (2026-11-06): it only ever handled inherited members, which went with inheritance. A real one is wanted once modules land.
70
- - **Leaked `plum run --no-open` servers** (2026-11-06): a test using `compiler/game/tests/fixtures/host_fixture.plum` left servers running for hours. Not found; the likely cause is `serveStartsAndAnswersWithTheRightContentTypes` in `compiler/cli/tests/cli/game_web_test.rs`, which only kills its child on the success path (the other spawning tests use a kill-on-drop guard).
71
- - **Locals named like functions, remaining cases** (found 2026-11-06, F-PUR-1 note, pre-existing, with or without fusion): in wasm-codegen, a flat local named like a free function traps or gives invalid wasm; a local in an embedded struct's `init` that captures a free call is silently wrong. The second goes away if inheritance is removed.
72
- - **Pattern-shadowed parameter gives invalid wasm** (found 2026-11-06, pre-existing, with or without fusion): a parameter shadowed by a pattern and read in a sibling arm compiles to wasm that won't load. Details in the game engine run's note `F-T6-2`.
73
- - **Closure self-call, still open** (`F-CLOSURE-1` fixed the typed-argument and arity checks; a self-call now errors in the checker when an argument does not fit a known parameter type). What stays: (a) a parameter with no declared type and no hint from a later call (`rec := |n| .. rec("x")` passed to `map`) has no type to check against; (b) `rec(None, [], n-1)` / `rec(Some(n), ..)` with untyped params still fail in codegen (invalid wasm or `type name 'Nil' is not yet supported as a value`), because the self-call's arguments are inferred with no expected type; checking them with the parameter as expected type fixes those but changes the wasm of programs that run today (e.g. a typed `Option[Int]` param called with `None`), so do it in a run that may re-baseline wasm; (c) a self-call from a nested closure (`outer := |n| inner := |m| outer(m-1) ..`) fails in codegen with `unknown function 'outer'`; (d) a typed declaration `f: fn(Int) -> Int := |n| ..` does not bind `f` inside its body; (e) a failed closure initialiser also reports a second `'rec' is not a function` at its first use.
74
- - **LSP columns are bytes, not UTF-16** (phase 4, pre-existing): non-ASCII text before an error underlines the wrong range. Spans take tree-sitter byte columns.
75
- - **Phase 4 workarounds still in place:** closure-hint twin mapping (`compiler/driver/src/lib.rs`, because `for` lowering numbers `pre` and the checked program separately) and `defaultSingleton` (`compiler/wasm-codegen/src/lib.rs`, because param defaults are never checked).
76
- - **Unproven, not reproduced (phase 4):** a discarded speculative failure could leave a stale `err_pos` on a later error; `Unit` from a missing type might panic in `scratchTypeIdx` on some pattern shape.
77
-
78
- - **Map as a balanced tree, and constant map literals** (user 2026-11-04, later) — reimplement `std/Map` as a persistent B-tree or AVL tree (a recursive enum, e.g. `Leaf | Node(left, key, value, right, height)`); keys need ordering instead of `Hashable`, iteration becomes sorted/deterministic. `[k => v, ..]` keeps desugaring to `Map.empty().set(k, v)...` (O(n log n)). Optional later optimisation: when every key in a literal is a compile-time constant, sort, dedupe and build the balanced tree directly at compile time.
79
- - **List literal cost** — `[a, b, c]` desugars to `Cons(head: a, tail: Cons(..., Nil))`, O(n); revisit if `List` changes representation.
80
-
81
- - **`List.length()` on a locally built list fails codegen** — `fun count() -> Int =` / `xs := List(1, 2)` / `xs.length()` gives `codegen: unknown method 'List.lengthFrom' (in 'count')`; the same call on a `List` parameter, or inside a `test` block, works. Also hit with a static `Hue.palette().length()`. Found drafting the kids' games; the user wants it fixed (with a regression test) before those games are built. Check whether the cleanup refactor already fixed it.
82
- - **Spread from a field path** — `Stage(..w.stage, x: 1)` is rejected; only a plain variable can be a spread source. Worked around with small helpers in the pure game. (language-restrictions T14)
83
- - **Fields declared inside `init` can't be `mut`** (`self.camX: Float = 0.0`) — such fields were moved into the record header. (T8)
84
- - **Benchmark harness can't pass `--no-fusion`** — `compiler/game/web-test` compiles without flags, so fusion-off numbers can't be taken since the env var was removed. (T11)
85
- - **`Orb`/`Mine` copy their shared `Node` per frame** in the pure game, because `Node`'s x/y/rotation stay immutable in std. Decide during FBIP. (T10)
86
- - **A nested spread allocates in a trait step** (actor-trait task 7, 2026-11-09): `Bod(..self, at: self.at.moveTo(x, y))` with `at: Place` allocates a cell per step that FBIP doesn't remove (Ship.step in a probe: one `struct.new` with a nested `Pos` spread), so the scene benchmark's step workload ran 1.7x slower than with `x`/`y` fields and a `place()` that builds the `Place`. So std's actors (`Group`, `Box`, ui's `Button` and `Label`) and the games keep plain `x`/`y` fields (actor-trait task 8); a value `Place` in a unique field is now written into its old box, but the boxed field still costs the step, and removing that needs a layout change.
87
- - **Struct fields have no defaults** (actor-trait task 6): the plan's `struct Place(x, y, scaleX: Float = 1.0, ..)` doesn't parse; std/game/scene/Place has `place.at(x, y)` and `place.turned(x, y, s, r)` instead.
88
- - **A generic call's result pinned only by a later parameter** (actor-trait task 6): `firstOf(Holder.of(Box(id: 5)).same())`, with `firstOf(h: Holder[Int])`, still instantiates `Box[Unit]` and fails codegen ("Box[Unit] has no compiled method 'key' for a call on Thing[Unit]"); an annotated local (`h: Holder[Int] := ..`) works. Likewise `SceneTree.of(Group(..))` with nothing fixing `M` is a `SceneTree[Unit]`: annotate it.
89
- - **Uniqueness precision** — `adv(Cell(..))` inlined into `main` reports "s used after its spread" although `s.x` is only read inside the spread value (a false "not in place"). (T10)
90
- - **Pattern-casing hint for union members** — "did you mean Foo?" doesn't cover a lowercase name that spells a union member (lookup lives in `compiler/core/src/unions.rs`). (T1)
91
- - **Constant `Anim` trees rebuilt every frame** in `games/functional/game_state_view.plum` (`renderTitle`, Ship render) — hoist them into `State` or constants. (F-T23-1)
92
- - **Static subtree reuse** in functional scenes (build unchanging parts of a picture once). Deferred by the user as a later optimisation. (state-view parity plan)
93
- - **Structural deep `==` for records** — user chose deep structural equality (like Rust `#[derive(PartialEq)]`), deferred before implementation; until then `==` on records is identity. (state-view parity T7)
94
- - **Retire PureScene?** — after the component-style functional game, decide whether `std/game/pure` + `games/pure` stay. (Decision record §4b)
95
- - **`adder(1)(2)`** (calling a returned closure directly) is not supported. (functional-gaps plan)
96
- - **Fusion past a closure-spec copy on `Nil` miscompiles** — in `drive.rs` `quiet`, resolving `Nil.fold$c0(..)` to `List.fold$c0` (read-only) lets a value move past it, and codegen then fails with `unknown method 'List.fold$c0'` (5 `closure_spec_test` cases). `typeNameMethodKey` skips `$` copies until this is fixed.
97
- - **Input model** — steps 1-3 built 2026-11-04 (typed `Msg` events for the functional style only); see [game-scene-styles.md](decisions/2026-11-game-scene-styles-analysis.md) section 6.
3
+ Open work on `simpler-language`, rewritten 2026-11-11. Only what is still open is here: finished and dismissed items were removed (history is in git and in `docs/plans/`). Numbers come from `docs/benchmarks/2026-11-11-simpler-language-before-after.md` unless a line says otherwise.
4
+
5
+ ## Decided, not built
6
+
7
+ - **Compile-time layer** (`docs/plans/2026-11-09-comptime-generics.review.md`). The `<>` syntax, the trait list in `[]` and the trait jump table from that plan are done. Still to build: `@hasMethod`, `@hasField`, `@fields`, `@field`, `comptime if` and `comptime for`, `@compileError`, `@embedFile`, `@src`, constants computed while compiling, `comptime fun`, value generics and type aliases, default type parameters, `Option` of a reference as a nullable reference (no allocation for `Some`, allocation-free `for` loops), derives in std (`hash`, `eq`, `toStr`, `lerp`, JSON), replay checksums with snapshot and rewind, easing and tweens in `Anim`.
8
+ - **`Clickable` as a compile-time flag.** The pointer walk tests each node with a trait downcast (one tag check). Once the compile-time layer exists, compute "is clickable" once at spawn and store it in the node. Needs a node field `RoseTree` does not have.
9
+ - **Testing** (user: "All 3 please"): `group "name"` blocks with scoped helpers; compare-mode tests (one flag runs a test with and without fusion and in-place updates); property tests in std (`check(|a, b| a + b == b + a)` with generated inputs).
10
+ - **Optional or automatic actor keys.** Most actors need no `key`. Either a default `key() -> Option<Int>`, or ids handed out by the tree from a counter and stored in the node. Open: how a spawner learns its child's id.
11
+ - **Constant map literals.** `[k => v]` lowers to `Map.empty().with(..)`, O(n log n). When every key is a compile-time constant, build the tree while compiling.
12
+
13
+ ## Performance
14
+
15
+ - **Compile time is worse than on 2026-11-10 morning**: 1.32x CPU for Orb Run (538 to 708 ms), 1.40x Balloon Pop, 2.0x for a small program, even after a 30% speed-up of the passes. Causes measured or likely: programs reach more std (+17% items for Orb Run), the in-place pass is now its own pass with its own re-check, the loader's threads add CPU. The program is still checked about 7 times per compile. Re-checking only changed functions was tried and dropped: type info is keyed by node id and instantiation numbering depends on whole-program order, so the output would change. Needs stable ids first. Pruning std before the first check fails because loop and `?` lowering add calls the raw program does not name.
16
+ - **`Map` insert allocates its whole path** (3.9x slower than the old hash table on raw sets and gets; 4.2x faster with 100 kept snapshots). Cell reuse for generic methods and a cheap `Int.compare` are being built on branch `perf/map-reuse`; update this line when it lands.
17
+ - **Closure calls are untyped.** A closure is held as `anyref`: each call does two casts and an indirect call, and building one allocates two objects. A typed closure struct per signature with `call_ref` would fix it. Indirect evidence: `cons_rec` (1.94 s) and `cons` without fusion (1.0 s) did not move.
18
+ - **A value struct inside an enum payload is boxed twice** (`Some(Pos)` allocates two objects). No measurement yet.
19
+ - **Scene tree with kept snapshots**: "60 kept" at N = 10000 costs 11 times a plain step. Ideas, all functional: a 32-way chunked vector for children instead of the sibling chain; skipping subtrees that cannot change; world transforms cached per node; reusing last frame's draw list when the root is the same object.
20
+ - **In-place updates still miss** 36 of Orb Run's 56 spreads. Reasons, by count: a value rebound by a pattern (8), the receiver read again after a method call (5), a shared value (4), a field passed on without being written back (4), an argument passed from inside a closure (4).
21
+ - **Static functions are slower than free functions** (0.78 s against 0.57 s on `benchmarks/static_calls`).
22
+ - **Smaller codegen items**: match arms test then cast (`br_on_cast` would do one check); the inliner skips leaves that use their locals (`unbox.*`); every struct has its own empty supertype; purity treats every closure-taking function as impure, so pipelines fuse only after closure specialisation.
23
+ - **The hover lookup costs about 3% per tick** (the context holds the tree being stepped).
24
+ - No evidence either way, so not planned: unchecked reads in `for` over a `Slice` (checked `at` showed no cost).
25
+
26
+ ## Bugs
27
+
28
+ - **A line that starts with an operator joins the line above.** `m := n * 2` followed by a line `|x| x + m`, or by `-x`, is read as one expression. The grammar's `body` rule needs real newline separators between statements (a large grammar change).
29
+ - **Negative literal patterns** (`-1.5 =>`) are a parse error.
30
+ - **Paths are named relative to the working folder** (`compiler/core/src/loader.rs`, about line 370): compiling from another folder embeds absolute paths in the wasm, so builds are reproducible on one machine but not across machines. The LSP's "elsewhere" check depends on the current behaviour.
31
+ - **`replay::tests::eachExampleGameReplaysARecordedRun` failed twice**, cause unknown. It records with a seed from the clock. A failure now saves its recording to `target/replay-failures/` and names the first differing draw call.
32
+ - **`pow` with a fractional exponent** is `exp(y * ln x)`: 23 ulp at `10.0.pow(10.5)`, 323 ulp at `10.0.pow(299.5)`. Needs a port of fdlibm's `e_pow.c`.
33
+ - **`m := [[], []]`** reports three errors where one would do.
34
+ - **A web `plum build -o`** leaves stale assets from a previous build in the folder.
35
+ - Small ones: after a duplicate-variant error the old type mismatch may still follow; the "function used as a value" error can misfire on a parameter of type `fn(Io, ..)` named like an extern; `Option.eq` on function payloads reports the enclosing function's line; LSP syntax diagnostics do not carry the hint lines; LSP completion panics are not caught; warnings in the grammar's `scanner.c`.
36
+
37
+ ## Language gaps
38
+
39
+ - **Type arguments on a static call's type** (`T<Int>.make()`) are not supported, and type arguments in an expression must be on one line.
40
+ - **Struct field defaults** (`struct Place(x: Float, scaleX: Float = 1.0)`) and **`fn` types as type arguments** (`Slice<fn(Int) -> Int>`): both need grammar changes.
41
+ - **No private members.** `Decimal`'s big-number helpers are public statics (`Decimal.bigAdd`).
42
+ - **No warnings.** A `hit` method on an actor that does not list `Clickable` is silently never called. Open question below.
43
+ - **A nested closure cannot call the outer self-calling closure** (a checker error today), and a self-calling closure whose parameter has no type and no later hint cannot be checked.
44
+ - From master's gap list, not yet looked at here: `..` in patterns, tests that expect a crash.
45
+
46
+ ## Std
47
+
48
+ - `Str.runeAt` returns an `Option` although `at` crashes everywhere else. Open question below.
49
+ - `Map.getEntryAt` is the `Option` form of `entryAt`; the name was an agent's choice.
50
+
51
+ ## Candidates from other branches (not started, not decided)
52
+
53
+ - From `self-hosting`: a WASI preview 2 target (`plum compile --target wasi`); running tests on the standalone wasmtime CLI and dropping the embedded host; `plum chrome` with a browser runtime for parity checks; `plum dump-ast` and its invalid-parse fixtures.
54
+ - From `master`: typed `Assets` with `Assets.none()` for tests; compiling a trait's default method once instead of once per implementer, if that is what happens here (not checked); the wasm-gc dispatch write-up.
55
+
56
+ ## Open questions for the user
57
+
58
+ 1. Should the checker gain warnings, starting with "`hit` without `Clickable`"?
59
+ 2. `Str.runeAt`: keep the `Option`, or crash like `at` and add `getRune`?
60
+ 3. `Map.getEntryAt`: keep the name?
61
+ 4. Which performance item first after the Map work: compile time, typed closure calls, or the scene tree with snapshots?
62
+ 5. Rerun the before/after benchmark on an idle machine? The 2026-11-11 run had a load average of 5 to 19 from other work.