Types phase 4: containers — map / set + fixed arrays [T; N] #54
Labels
No labels
area:ci
area:docs
area:input
area:net
area:rendering
area:repo
area:stdlib
area:tooling
area:types
cleanup
dx
priority:high
priority:low
priority:medium
proposal
status:in-progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: workshopsoft/ludic#54
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #1 (proposal), phase 4 of the phasing.
map<K,V> — lookups by id/name (loot tables, entity registries, config), like Go
map/ C#Dictionary.set — membership (tags, visited tiles, unlocked achievements).
[T; N] fixed arrays — grids, inventories, per-entity slots with no heap; already a design target in LANGUAGE.md.
grid — a tilemap of any element type (today
Map.*is a fixed char grid); could be sugar over[T; W*H].These need a generics-lite mechanism in the front end; scope that first.
Phase 1 (IVec2 + Rect) shipped in the #1 thread.
Shipped —
Dict+Set(539f258)Types phase 4, containers, is done. One open-addressing hash table (
runtime/native/dict.ludic— FNV-1a hash, linear probing, tombstone deletes, grows at load factor 0.7) is spliced in on demand and exposed as two namespaces:Dict.*— a map from string keys tointvalues.new/set/get/get_or/has/remove/size/clear/keys. For resource counts and id/name registries (loot tables, entity registries, config). O(1) average lookup instead of the linear scan a list would give.Set.*— a set of string members.new/add/has/remove/size/clear/members. For tags, unlocked achievements and visited tiles. Shares the same table (a Set is a Dict whose values are ignored).Values are
int, which also holds anentityhandle or any small id.Scope notes for this phase:
Value.*tree (#44) — a string→Value object — soDict/Setdeliberately specialise to the fast, common string→int case rather than reinventing a generic container without a generics mechanism in the front end.[T; N]inline fixed arrays andgrid<T>remain future work: they need parser/type-system support for a new array syntax. The typed bufferswords/fixeds/pointersplus[]Tslices already cover heap-backed arrays today, andGrid.*(#24) covers char tilemaps. I have left this out rather than ship a half-generic array type.Wired end to end: parser splice trigger (
g_uses_dict),emit_calldispatch, reseeded C-free seed, a self-asserting example (examples/library/containers.ludic, 14 assertions incl. a rehash-growth check, in the regression suite), and per-symbol docs + section + inventory. All suites green:x test83/83,x selfhost-test30/30 (golden renders byte-identical, bootstrap fixpoint holds),x test-tools30/30,check-impl/check-vocabulary/check-docs.Closing phase 4. Phases 3 and 5 remain in #53 / #55.