plum

#treesitter#compiler#wasm

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

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


b61c94e — Peter John 2026-11-01T21:03:49+05:30
docs: dop_visitor header describes record members
Files changed (1) hide show
  1. plum-examples/dop_visitor.plum +6 -6
plum-examples/dop_visitor.plum CHANGED
@@ -7,12 +7,12 @@
7
7
  # article's Java (sealed interfaces implemented directly by records, switch
8
8
  # with `when` guards and deconstruction):
9
9
  #
10
- # - Each variant carries its fields inline, right in the enum (e.g.
10
+ # - Each variant is its own `record` declaration (e.g. `record
11
- # `FantasyBook(title: Str, pages: Int, hasMythicalCreatures: Bool)`), so
11
+ # FantasyBook(title: Str, pages: Int, hasMythicalCreatures: Bool)`), listed
12
- # there's no separate `type` declaration to wrap — the named fields are
12
+ # as a member of the union enum (`enum Book = FantasyBook | ScifiBook | ...`).
13
- # just call-site sugar (`FantasyBook(title: ..., ...)` or positional
13
+ # Construct with named fields (`FantasyBook(title: ..., ...)`) or
14
- # `FantasyBook(...)`), and a match arm still destructures purely by
14
+ # positionally, and a match arm destructures each member by position
15
- # position (`FantasyBook(title, pages, hasMythicalCreatures)`).
15
+ # (`FantasyBook(title, pages, hasMythicalCreatures)`) or by name.
16
16
  # - A `when <expr>` guard on a match case (`FantasyBook(title, _,
17
17
  # hasMythicalCreatures) when hasMythicalCreatures => ...`) stands in for
18
18
  # Java's guarded switch patterns; a guard that evaluates false falls