feat(lang,stdlib): 64-bit long type + 64-bit Hash variants (issue #17)
Some checks are pending
docs / build-and-deploy (push) Waiting to run
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>
This commit is contained in:
parent
a38195128f
commit
2002e977d9
27 changed files with 14007 additions and 12105 deletions
26
docs/language/hash/hash-fnv1a_64.md
Normal file
26
docs/language/hash/hash-fnv1a_64.md
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
id: hash-fnv1a_64
|
||||
name: Hash.fnv1a_64
|
||||
category: hash
|
||||
kind: namespace-method
|
||||
tokens: Hash.fnv1a_64
|
||||
sig: Hash.fnv1a_64(s) -> long
|
||||
tip: FNV-1a 64-bit, named explicitly.
|
||||
order: 7
|
||||
ns: Hash
|
||||
member: fnv1a_64
|
||||
---
|
||||
|
||||
The 64-bit <a href="https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function">FNV-1a</a> hash of a string's bytes, returned as a <code>long</code>. It uses the standard 64-bit offset basis <code>0xcbf29ce484222325</code> and prime <code>0x100000001b3</code>: for each byte, XOR it in and multiply by the prime. Its wider output makes accidental collisions vanishingly unlikely for the id and registry use cases games hit. This is the function <a href="hash-of64"><code>Hash.of64</code></a> delegates to; call <code>Hash.fnv1a_64</code> when you want the algorithm pinned by name.
|
||||
|
||||
Parameters:
|
||||
- `s` — the string to hash
|
||||
|
||||
```ludic
|
||||
program Fnv64 {
|
||||
entry {
|
||||
print(Hash.fnv1a_64("")) # the empty string -> the 64-bit offset basis
|
||||
print(Hash.fnv1a_64("grass_tile"))
|
||||
}
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue