plum

#treesitter#compiler#wasm

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

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


ad2cf07 — Peter John 2026-11-09T20:12:56+05:30
Backlog: a faster SceneTree step that stays functional
Files changed (1) hide show
  1. docs/backlog.md +6 -0
docs/backlog.md CHANGED
@@ -29,6 +29,12 @@ Open work, in the order the user queued it, plus smaller items found during buil
29
29
 
30
30
  - **Generics in `<>`, traits in `[]`** (user 2026-11-09, later): `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
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:** after `step`, if the actor is the same reference (`ref.eq`, default `step` returns `self`) and its children are unchanged, keep the old node and allocate nothing. Optionally a cached per-node "subtree can change" flag, so still subtrees (menus, HUD) are skipped whole, like Flutter `const` or React `memo`. Helps real games; not the all-actors-move benchmark, so add a "mostly static" workload.
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.
32
38
  - **Testing improvements** (user 2026-11-06, "All 3 please", and "Yes please add group"):
33
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.
34
40
  - **One test command:** runs every Rust test executable plus the sweep. Comes right after the current fix in the simpler language run.