- `[a, b, c]` list literals (E_LIST → emit_list); static_type learns slice-element, `new T`, list, string and literal kinds - `x op= y` lowers through the same path as `x = x op y` (emit_bin_vals): fixed `*=`/`/=` use the Q16.16 64-bit paths, string `+=` concatenates, int→long widens; unary `-` keeps a fixed operand's type (arith_ty) - one `unescape()` table for "strings", 'chars' and `interpolation`; `'\''`, `'\\'`, `'\"'` no longer read as 0; unterminated char literals and unexpected characters are errors instead of silently skipped - every diagnostic is `file:line: error: msg` (g_parse_file / g_err_file, Node.file + Node.line set by node()); tok_desc() in expectation errors; duplicate `function` names and unknown `phase` names are reported in source terms (phase_id used to default unknown phases to Overlay) - interpolation holes skip braces inside string literals - hand-IR preludes move from the user `@fn_` prefix to `@lp_` so a user `is_ws` / `str_eq` / `path_join` no longer collides at link time - `@ClearColor(expr)` accepts any constant expression; `Os.pid()` added (docs page + inventory); `str_starts()` in support/str - main.ludic: `else if` flag ladder, char literals, stale script comments - examples/lang/operators.ludic covers all of the above; os.ludic covers Os.pid; docs pages for Os.pid and the Overlay phase; ten changesets - reseeded: selfhost/ludicc.seed.ll is the new compiler's own fixpoint Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
28 lines
1.1 KiB
Markdown
28 lines
1.1 KiB
Markdown
---
|
|
id: hash-crc32
|
|
name: Hash.crc32
|
|
category: hash
|
|
kind: namespace-method
|
|
tokens: Hash.crc32
|
|
sig: Hash.crc32(s) -> int
|
|
tip: CRC-32 checksum for corruption detection.
|
|
order: 3
|
|
ns: Hash
|
|
member: crc32
|
|
---
|
|
|
|
The <a href="https://en.wikipedia.org/wiki/Cyclic_redundancy_check">CRC-32</a> checksum of a string's bytes — the standard IEEE 802.3 variant (reflected polynomial <code>0xEDB88320</code>), the same one used by zip, gzip and PNG. Its well-known check value: <code>Hash.crc32("123456789")</code> is <code>0xCBF43926</code>. 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
|
|
|
|
```ludic
|
|
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
|
|
}
|
|
}
|
|
```
|