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>
1.1 KiB
1.1 KiB
| id | name | category | kind | tokens | sig | tip | order | ns | member |
|---|---|---|---|---|---|---|---|---|---|
| hash-crc32 | Hash.crc32 | hash | namespace-method | Hash.crc32 | Hash.crc32(s) -> int | CRC-32 checksum for corruption detection. | 3 | Hash | crc32 |
The CRC-32 checksum of a string's bytes — the standard IEEE 802.3 variant (reflected polynomial 0xEDB88320), the same one used by zip, gzip and PNG. Its well-known check value: Hash.crc32("123456789") is 0xCBF43926. Use it to catch accidental corruption in a save file, downloaded asset, or config blob: store the checksum alongside the data and compare on load. It detects damage, not tampering — an attacker can trivially forge a matching CRC, so it is not a security check (see the section note).
Parameters:
s— the string (bytes) to checksum
program Checksum {
entry {
let data = "save:level=3;coins=120"
let ck = Hash.crc32(data) # store this next to the save; recompute on load
print(ck)
print(Hash.crc32(data) == ck) # 1 — unchanged data checks out
}
}