plum

#treesitter#compiler#wasm

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

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


4979680 — Peter John 2026-11-09T12:46:45+05:30
Plan: bring master's Game and screens over on traits (task 9); the tree is Stage
docs/plans/2026-11-09-actor-trait.md CHANGED
@@ -235,7 +235,7 @@ tree). After this work:
235
235
  - `ETree` moves to `std/collections/functional/FRoseTree.plum` as `FRoseTree[T]`, a plain
236
236
  generic collection.
237
237
  - `std/game/scene` is the retained scene on `FRoseTree[Actor]`. The names drop the `E`:
238
- `Scene` (was `EStage`), `Actor`, `Place`, `Ctx`, `Cmd`, `Spawn`, `Kill`, `Drawn`,
238
+ `Stage` (was `EStage`; `Scene` is a screen, see "Game and screens"), `Actor`, `Place`, `Ctx`, `Cmd`, `Spawn`, `Kill`, `Drawn`,
239
239
  `Group`, `Box`.
240
240
  - Deleted: std/game_enum_tree, and the immediate-mode `SceneNode[M]` with `Clickable`
241
241
  and `msgOf`.
@@ -249,6 +249,26 @@ tree). After this work:
249
249
  what it still buys on the retained tree.
250
250
  - benchmarks/scene_trees: one branch entry, the new scene.
251
251
 
252
+ ## Game and screens (from master)
253
+
254
+ Master's std/game has `Game(scene, state)`, `Scene(stage)` (one screen: title, play, game
255
+ over), `Stage` (the actor tree), `State.reduce` with `Actions` (a Redux dispatcher) and
256
+ std's `Restart`, `Exit` and `GoTo(scene)`. The branch already has the fixed-tick `Clock`
257
+ (std/game/input) and record and replay (std/game/Replay), ported by plum-63. Master's code
258
+ is built on struct embedding and `&self` mutation, which the branch doesn't have, so the
259
+ ideas come over on traits, not the code:
260
+
261
+ | master | branch |
262
+ |---|---|
263
+ | `Stage` (actor tree) | `Stage` on `FRoseTree[Actor]` (this doc's retained tree; named `Stage` as on master) |
264
+ | `Scene` (one screen, subclassed) | `trait Scene[S, M]`: `update(self, io, input, dt, store) -> (Self, Store[S, M])`, optional `draw(self, io)` defaulting to drawing its stage |
265
+ | `State` + `reduce` + `Actions` | `Reducer[M]` + `Store[S, M]` (`dispatch` reduces at once, effects after the tick, as master) |
266
+ | `Restart`, `Exit`, `GoTo(scene)` | std messages the `Game` applies after the tick, before the game's `handle` |
267
+ | `Game(scene, state)` | `Game[S, M](scene: Scene[S, M], store: Store[S, M])`, a trait object for the current screen |
268
+
269
+ A game's `main` returns a `Game`; the host drives it as now. Screens switch only between
270
+ ticks. A game with one screen may keep its own `update` and skip `Game`.
271
+
252
272
  ## The port
253
273
 
254
274
  - examples/games/orb_run_tree.plum: the `Kind` enum becomes structs (`Star`, `Orb`,
@@ -281,7 +301,10 @@ tree). After this work:
281
301
  7. The port of orb_run_tree.plum and the benchmark, with the headless comparison.
282
302
  8. One scene system: the new scene becomes `std/game/scene`; ui.plum, orb_run,
283
303
  balloon_pop, the web-test fixtures and docs/game.md move to it; `SceneNode`, its
284
- fusion, and std/game_enum_tree are deleted.
304
+ fusion, and std/game_enum_tree are deleted. The tree type is named `Stage`.
305
+ 9. Game and screens: std/game/Game.plum with `trait Scene[S, M]`, `Game[S, M]`, `Restart`,
306
+ `Exit` and `GoTo`, as in "Game and screens (from master)"; orb_run's title, play and
307
+ game over become screens; docs/game.md and tests.
285
308
 
286
309
  Tasks 1 to 4 are compiler work. Agree them with the session porting master's changes
287
310
  (plum-63) before starting, since it edits the parser and checker.