plum
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
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
|
|
10
|
+
# - Each variant is its own `record` declaration (e.g. `record
|
|
11
|
-
#
|
|
11
|
+
# FantasyBook(title: Str, pages: Int, hasMythicalCreatures: Bool)`), listed
|
|
12
|
-
#
|
|
12
|
+
# as a member of the union enum (`enum Book = FantasyBook | ScifiBook | ...`).
|
|
13
|
-
#
|
|
13
|
+
# Construct with named fields (`FantasyBook(title: ..., ...)`) or
|
|
14
|
-
#
|
|
14
|
+
# positionally, and a match arm destructures each member by position
|
|
15
|
-
#
|
|
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
|