Proposal: UUID library (Uuid.*) — v4 random + v7 time-ordered IDs for multiplayer, saves, mods #16
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#16
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?
Summary
A tiny built-in UUID library — generate and parse universally-unique
identifiers (v4 random, and v7 time-ordered) — for stable IDs that don't collide.
Why it matters for game devs
central authority handing out numbers.
survive merges and sharing.
Proposed API (illustrative)
new(v4),new_v7(time-ordered),parse,to_text,equals,nil.Considerations
deterministic simulation RNG (IDs are non-deterministic input; document this so
people don't break replays/lockstep by minting UUIDs in gameplay).
Scope / acceptance
parse/to_text/equals/nil, with parse returning an error value.Related: Time, Crypto/RNG, error handling, networking proposals.
Done in commit
2ddf830.Added the
Uuid.*namespace:Uuid.new/Uuid.v4) — 122 random bits from the OS CSPRNG.Uuid.new_v7/Uuid.v7) — 48-bit Unix-ms timestamp prefix + random tail, so IDs sort by creation time; version/variant bits set per RFC 4122.Uuid.parse(normalises untrusted input to lowercase, or the nil UUID),Uuid.is_valid,Uuid.to_text,Uuid.equals(case-insensitive),Uuid.nil.Represented as the canonical lowercase 36-char string (the form you store/print/send/compare), reusing the crypto prelude's CSPRNG + hex encoder. The determinism caveat is documented: v4 and v7's random tail are non-deterministic, so mint IDs at the edges, never inside lockstep simulation.
Acceptance:
parse/to_text/equals/nil— parse folds invalid input to nil; pair withis_validto rejectTests:
examples/library/uuid.ludic(wired intox test). Docs: newdocs/language/uuid/section.Note on error handling: the sketch's
try Uuid.parse(s) else ...awaits the error-handling proposal (#8); until thenparsereturns nil on bad input andis_validis the explicit reject path.