plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
1e8b748
— Peter John
2026-11-10T22:01:10+05:30
std: comments no longer describe Map as a hash table, Set as mutable or std/ref
- docs/std.md +1 -1
- std/Array.plum +4 -10
- std/Float.plum +5 -4
- std/collections/Bvh.plum +2 -2
docs/std.md
CHANGED
|
@@ -16,7 +16,7 @@ The [game engine](game.md) has its own page.
|
|
|
16
16
|
| [`Json`](#json) | reading and writing JSON |
|
|
17
17
|
| [`Decimal`](#decimal) | exact decimal numbers, to and from `Float` |
|
|
18
18
|
| [`Os`, `http`](#files-and-network) | files and the network |
|
|
19
|
-
| [`Time`, `Random`, `Uuid`, `Base64`, `Aabb`, `
|
|
19
|
+
| [`Time`, `Random`, `Uuid`, `Base64`, `Aabb`, `@sameRef`](#utilities) | utilities |
|
|
20
20
|
| [`testing`](#testing) | helpers for tests |
|
|
21
21
|
| [`game/Store`](#game-state-store) | a game's state as a `Reducer`, and its messages |
|
|
22
22
|
|
std/Array.plum
CHANGED
|
@@ -26,16 +26,10 @@ import std/Byte
|
|
|
26
26
|
# there's no way to express raw array allocation/indexing in Plum source itself.
|
|
27
27
|
# `Slice<T>` is built on this.
|
|
28
28
|
#
|
|
29
|
-
# `init()` is deliberately zero-arg (no `Array<T>(n)` constructor exists)
|
|
29
|
+
# `init()` is deliberately zero-arg (no `Array<T>(n)` constructor exists): a sized array
|
|
30
|
-
# `
|
|
30
|
+
# is `Array.filled(n, v)` or `Array<T>().resize(n)`. `push` allocates a new array one
|
|
31
|
-
# value` field arguments or an empty arg list, never bare positional ones
|
|
32
|
-
# (see `tooling/tree-sitter-plum/grammar.js`'s `class_argument_list`), and
|
|
33
|
-
# `Array` has no real fields for a keyword arg to bind to. Building a
|
|
34
|
-
# specific-length array is `push`ing onto an empty one `n` times instead
|
|
35
|
-
# (`Map`'s bucket array does exactly this at construction) — `push` itself
|
|
36
|
-
# has no in-place "grow" to fall back on either (a wasm-gc `array` is a
|
|
37
|
-
#
|
|
31
|
+
# longer and copies (a wasm-gc `array` has a fixed length once made), so filling an array
|
|
38
|
-
#
|
|
32
|
+
# by `push` is O(n^2): size it first.
|
|
39
33
|
#
|
|
40
34
|
# New slots are the wasm default: null for a reference `T` (so `get` on a
|
|
41
35
|
# never-`set` index traps), zero for a value `T` (`Int`/`Float`/`Bool`/`Byte`).
|
std/Float.plum
CHANGED
|
@@ -60,10 +60,6 @@ primitive Float =
|
|
|
60
60
|
else
|
|
61
61
|
self
|
|
62
62
|
|
|
63
|
-
# The bits (`toBits`), so `0.1` and `0.2` hash apart; `Map` and `Hamt` avalanche them as
|
|
64
|
-
# they do an Int's. Floats that are `==` hash the same: `0.0` and `-0.0` both hash to 0.
|
|
65
|
-
# Every NaN hashes the same (to the bits of `0.0 / 0.0`, as wasm makes it), though a NaN is
|
|
66
|
-
# never `==` to anything, so it never finds itself as a key.
|
|
67
63
|
# A total order for `Map` keys: -1, 0 or 1 as `self` is below, equal to or above `o`.
|
|
68
64
|
# `-0.0` and `0.0` compare equal, and every NaN equals every other NaN and comes after
|
|
69
65
|
# `Infinity`.
|
|
@@ -79,6 +75,11 @@ primitive Float =
|
|
|
79
75
|
else
|
|
80
76
|
-1
|
|
81
77
|
|
|
78
|
+
# The bits (`toBits`), so `0.1` and `0.2` hash apart; `Hamt` avalanches them as it does
|
|
79
|
+
# an Int's. Floats that are `==` hash the same: `0.0` and `-0.0` both hash to 0. Every NaN
|
|
80
|
+
# hashes the same (to the bits of `0.0 / 0.0`, as wasm makes it), though a NaN is never
|
|
81
|
+
# `==` to anything, so it never finds itself as a Hamt key (a `Map` key uses `compare`,
|
|
82
|
+
# under which every NaN is the same key).
|
|
82
83
|
fun hash(self) -> Int =
|
|
83
84
|
if self == 0.0f
|
|
84
85
|
0
|
std/collections/Bvh.plum
CHANGED
|
@@ -231,8 +231,8 @@ enum BvhNode<V> =
|
|
|
231
231
|
BvhEmpty => acc
|
|
232
232
|
|
|
233
233
|
# ---------------------------------------------------------------------------
|
|
234
|
-
# Test helpers. Tests may use loops, `mut` fields
|
|
234
|
+
# Test helpers. Tests may use loops, `mut` fields, std's mutable `Slice` and the `Set`
|
|
235
|
-
# as the brute-force reference model; the structure above may not.
|
|
235
|
+
# as the brute-force reference model; the structure above may not use the `Slice`.
|
|
236
236
|
# ---------------------------------------------------------------------------
|
|
237
237
|
|
|
238
238
|
fun bvhNextRand(x: Int) -> Int =
|