plum

#treesitter#compiler#wasm

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

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


2c66562 — Peter John 2026-11-10T22:31:03+05:30
games: drop the annotated-local workarounds that are no longer needed
examples/games/kids/balloon_pop.plum CHANGED
@@ -354,11 +354,7 @@ struct SkyScreen[Screen<State, Msg>](id: Int) =
354
354
  # The balloons of `t`, in tree order: the children of their layer.
355
355
  fun balloonsOf(t: SceneTree<Msg>) -> List<Balloon> = t.kidsAs<Balloon>(BalloonLayer)
356
356
 
357
- fun firstBalloon(t: SceneTree<Msg>) -> Balloon =
357
+ fun firstBalloon(t: SceneTree<Msg>) -> Balloon = t.kidsAs<Balloon>(BalloonLayer).at(0)
358
- # Bound to an annotated local first: `t.kidsAs<Balloon>(..).at(0)` straight on fails in
359
- # codegen with fusion on (`unknown function 'get$kidsAs$0'`).
360
- bs: List<Balloon> := balloonsOf(t)
361
- bs.at(0)
362
358
 
363
359
  # A new game's tree and state.
364
360
  struct Play(tree: SceneTree<Msg>, state: State)
examples/games/orb_run.plum CHANGED
@@ -9,11 +9,12 @@
9
9
  # fits the arena on screen; the state names the one shown (`State.on`, set by `update`:
10
10
  # `PlayScreen.name()` when a run starts), and only that one steps and is drawn. The play
11
11
  # screen fades in over the title. Every kind of body is its own struct (`Ship`, `Orb`,
12
- # `Mine`, `Star`, `Icon`, ..) with only its own fields, and implements `Actor<Msg>`: it says which
12
+ # `Mine`, `Star`, `Icon`, ..) with only its own fields, and implements `Actor<Msg>`: it
13
- # actor it is (`key`) and where (`place`, made from its plain `x` and `y`), and writes
13
+ # says which actor it is (`key`) and where (`place`, made from its plain `x` and `y`), and
14
- # only the behaviour it has: its next version (`step`), its drawing (`paint`). None of
14
+ # writes only the behaviour it has: its next version (`step`), its drawing (`paint`). None
15
- # them is `Clickable`, so the pointer passes them by. The ship steers itself from the tick's held keys (`ctx.input`) and the
15
+ # of them is `Clickable`, so the pointer passes them by. The ship steers itself from the
16
+ # tick's held keys (`ctx.input`) and the root camera fits itself to the screen
16
- # root camera fits itself to the screen (`ctx.view`). The backdrop and the dimmer are
17
+ # (`ctx.view`). The backdrop and the dimmer are
17
18
  # std's `Box`, the layers std's `Group`, the text std/game/ui's `Label` and the buttons
18
19
  # ui's `Button`, which send their `onClick` message when clicked.
19
20
  #
@@ -641,10 +642,7 @@ struct Bodies(ship: Option<Ship>, orbs: List<Orb>, mines: List<Mine>)
641
642
  # The bodies of the play screen's tree `t`, read in one walk along the screen's children
642
643
  # (the ship, and the orb and mine layers), so the stars are never visited.
643
644
  fun bodiesOf(t: SceneTree<Msg>) -> Bodies =
644
- none: Option<Ship> := None
645
- orbs: List<Orb> := Nil
646
- mines: List<Mine> := Nil
647
- layersFrom(t.root.kids(), Bodies(ship: none, orbs: orbs, mines: mines))
645
+ layersFrom(t.root.kids(), Bodies(ship: None, orbs: Nil, mines: Nil))
648
646
 
649
647
  fun layersFrom(c: RoseTree<Actor<Msg>>, b: Bodies) -> Bodies = match c
650
648
  RoseEmpty => b
@@ -780,7 +778,7 @@ fun onShip(g: Game<State, Msg>) -> Motion =
780
778
  fun emptyGame(io: Io) -> Game<State, Msg> = mapped(started(io, 7), |a| placedAt(a, away()))
781
779
 
782
780
  fun withState(g: Game<State, Msg>, s: State) -> Game<State, Msg> =
783
- store: Store<State, Msg> := Store.of(s)
781
+ store := Store.of(s)
784
782
  Game(..g, store: store)
785
783
 
786
784
  # A game over with the score `score`: the one life left lost to a mine.