Proposal: non-cryptographic hashing (Hash.*) — map keys, content IDs, deterministic seeds, checksums #17
Labels
No labels
area:ci
area:docs
area:input
area:net
area:rendering
area:repo
area:stdlib
area:tooling
area:types
cleanup
dx
priority:high
priority:low
priority:medium
proposal
status:in-progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: workshopsoft/ludic#17
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
A non-cryptographic hashing library for everyday game needs: hashing keys
for maps, content IDs, checksums, deterministic seeds, and change detection.
(Cryptographic/secure hashing is tracked separately — see the Crypto issue.)
Why it matters for game devs
"grass_tile"into a fast integer handle.(world_seed, chunk_x, chunk_y)into a per-chunkseed for procedural generation (pairs with the Noise proposal #3).
Proposed API (illustrative)
Hash.of+Hash.combine.crc32for checksums; expose a couple of named algorithms explicitly.Considerations
and run (fixed seed, defined byte order). This is what makes it usable for
procedural generation and networking. Document it loudly.
in the docs to prevent misuse.
Scope / acceptance
Hash.of,Hash.combine,Hash.crc32, one named fast algo, 32/64-bit.Related: #3 (Noise), Crypto, Filesystem (checksums), networking.
Done — shipped in
2002e97(pushed tomain).The
Hash.*namespace now provides both 32- and 64-bit algorithms, all deterministic and C-free:int):Hash.of,Hash.fnv1a,Hash.crc32,Hash.mix,Hash.combine(...)long):Hash.of64,Hash.fnv1a_64,Hash.mix64Delivering the 64-bit variants required a real language extension — a new
long(64-bit signed integer) primitive type — landed in the same commit (llty -> i64, int/long coercion, i64 arithmetic/comparison, print/str, editor vocab sync).Acceptance: Hash.of/combine/crc32 + a named fast algo in 32- AND 64-bit; deterministic + documented cross-platform guarantee (fixed constants, defined byte order, pure integer IR -> bit-identical everywhere); docs page with the "don't use this for security" note + a chunk-seed example (docs/language/hash/); known-answer tests (CRC-32 poly 0xEDB88320 and FNV vectors verified against reference impls) + a long language test (selfhost/tests/{hash,long}.ludic).
Note: numeric literals are still parsed as 32-bit, so large long values are built by widening (documented on the type page). Prior namespaced-stdlib groundwork:
a381951.