Types phase 4 — containers. A splice-on-demand open-addressing hash table (runtime/native/dict.ludic, FNV-1a, linear probing, tombstones, grow at 0.7) behind two namespaces: - Dict.* — string -> int map: new/set/get/get_or/has/remove/size/clear/keys. Resource counts, id/name registries. O(1) average vs a linear list scan. - Set.* — set of strings: new/add/has/remove/size/clear/members. Tags, unlocked achievements, visited tiles. Shares the same table. Values are int (also an entity handle / small id); Value.* covers richer maps. [T; N] inline fixed arrays remain future work — typed buffers and []T slices already cover heap-backed arrays. Wired: parser splice trigger (g_uses_dict), emit_call dispatch, reseeded seed, a self-asserting example (examples/library/containers.ludic + feat_case), and per-symbol docs + inventory. All suites green incl. golden renders byte- identical and the bootstrap fixpoint. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
490 B
490 B
| id | name | category | kind | tokens | sig | tip | order | ns | member |
|---|---|---|---|---|---|---|---|---|---|
| dict-get_or | Dict.get_or | dict | namespace-method | Dict.get_or | Dict.get_or(d, key, fallback) -> int | Look up a key with an explicit default. | 3 | Dict | get_or |
Returns the value for key, or fallback when the key is absent — the unambiguous lookup when 0 could be a real value.
program Demo {
handler Step phase Update {
let n = Dict.get_or(bank, "stone", 0 - 1)
}
}