ludic/docs/language/hash/hash-mix64.md
Orkuncakilkaya 2002e977d9
Some checks are pending
docs / build-and-deploy (push) Waiting to run
feat(lang,stdlib): 64-bit long type + 64-bit Hash variants (issue #17)
Add `long`, a 64-bit signed integer primitive (i64), threaded through
codegen: llty; int<->long coercion (coerce_code/to_long) at let/assign/
return/call-args; i64 arithmetic + comparison promotion in emit_bin;
unary negate/~; print via %lld and str()/interpolation via @fn_long_str.
Editor vocabulary (syntax header, TextMate grammar, formatter, LSP)
synced; check-vocabulary green. Numeric literals stay i32 — build large
values by widening (documented on the type page).

Complete the Hash.* namespace (issue #17) with both 32- and 64-bit
algorithms: Hash.of/fnv1a/crc32/mix/combine (32-bit) and
Hash.of64/fnv1a_64/mix64 (64-bit, returning long). Deterministic and
C-free; CRC-32 (poly 0xEDB88320) and FNV vectors verified against
reference implementations.

Tests: selfhost/tests/{hash,long}.ludic. Docs: docs/language/hash/*,
type-long.md. Seed reseeded; C-free bootstrap fixpoint holds; 23
selfhost + 45 regression + 29 tooling checks green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-30 01:01:06 +03:00

27 lines
1,016 B
Markdown

---
id: hash-mix64
name: Hash.mix64
category: hash
kind: namespace-method
tokens: Hash.mix64
sig: Hash.mix64(x) -> long
tip: Avalanche one 64-bit integer into a well-scrambled value.
order: 8
ns: Hash
member: mix64
---
The 64-bit counterpart of <a href="hash-mix"><code>Hash.mix</code></a>: the <a href="https://en.wikipedia.org/wiki/MurmurHash">MurmurHash3</a> <code>fmix64</code> finalizer (shift by 33, multiply, repeat). It thoroughly scrambles a <code>long</code>, so consecutive or structured inputs map to unrelated-looking outputs — ideal for turning a large counter, packed coordinate, or 64-bit id into a random-looking seed. An <code>int</code> argument widens to 64 bits first. Deterministic; <code>Hash.mix64(0)</code> is <code>0</code>.
Parameters:
- `x` — the integer to avalanche (widened to `long`)
```ludic
program Seeds64 {
entry {
let base: long = Hash.of64("chunk")
print(Hash.mix64(base))
print(Hash.mix64(base + 1)) # a neighbouring input -> an unrelated seed
}
}
```