Some checks are pending
docs / build-and-deploy (push) Waiting to run
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>
30 lines
1.2 KiB
Markdown
30 lines
1.2 KiB
Markdown
---
|
|
id: hash-combine
|
|
name: Hash.combine
|
|
category: hash
|
|
kind: namespace-method
|
|
tokens: Hash.combine
|
|
sig: Hash.combine(...) -> int
|
|
tip: Fold several ints into one deterministic seed.
|
|
order: 5
|
|
ns: Hash
|
|
member: combine
|
|
---
|
|
|
|
Mixes any number of integers into a single 32-bit value. It folds the arguments left to right with the classic hash-combine step (each value is spread with the golden-ratio constant <code>0x9e3779b9</code> and stirred into the running seed), so the result depends on every input and on their order — <code>Hash.combine(1, 2, 3)</code> and <code>Hash.combine(3, 2, 1)</code> differ. The whole point is a per-thing deterministic seed: hash a world seed with a chunk's coordinates to drive procedural generation, so the same chunk always regenerates identically. Pair it with the noise and random libraries, which take a seed.
|
|
|
|
Parameters:
|
|
- `...` — the integers to combine (one or more)
|
|
|
|
```ludic
|
|
program ChunkSeed {
|
|
entry {
|
|
let world_seed = 1337
|
|
let cx = 4
|
|
let cy = -2
|
|
let seed = Hash.combine(world_seed, cx, cy) # this chunk's stable seed
|
|
print(seed)
|
|
print(Hash.combine(world_seed, cx, cy) == seed) # 1 — reproducible
|
|
}
|
|
}
|
|
```
|