Types phase 5: polish — huge (idle), sized ints, angle / percent / handle / duration / rune / name #55
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#55
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 5 of the phasing.
entity, so asset/entity handles can't be mixed up with a bare int.rune).Phase 1 (IVec2 + Rect) shipped in the #1 thread.
Shipped —
Huge+Angle+Percent(5dc8394)Types phase 5, the "polish" grab-bag. A splice-on-demand numeric runtime (
runtime/native/numeric.ludic, built on the inline deterministicMath.*trig) exposes three namespaces:Huge.*— idle/incremental big numbers, a normalized mantissa × 10^exponent that reaches far past the integer range.from/add/sub/mul/neg/cmp/sign/mantissa/exp/str(scientific, e.g.1.00e12). As the proposal specifies, this is display-scale, not lockstep-exact (~4 significant digits) — kept out of the deterministic sim;BigInt/Decimalcover exactness.Angle.*— an auto-wrapping radian angle, so no manual% TAU.from_degrees/to_degrees/wrap/sin/cos/add/diff(shortest signed rotation) /lerp(shortest arc).Percent.*— a value clamped to[0, 1]for health fractions, volumes and interpolationt.clamp/of/lerp/apply.The rest of phase 5
The remaining items on the list are already covered or need a language feature I have deliberately not rushed:
duration/tick— already shipped as theDuration.*namespace (time units).rune/char— already covered byUnicode.*(code-point handling).i64— already exists as thelongtype; the other sized ints (u8/i16/u16/u32/u64) are packing/serialization widths.handle(typed id) and a typedname/interned string — these are about nominal type safety (a handle that cannot be mixed up with a bare int). Ludic has no validation pass yet (unknown types lower toptr, arity/type mismatches are not checked), so a safety wrapper cannot actually enforce anything today. These, and the remaining sized-int types, are the natural payoff of a type-checking pass and are best done together with it rather than as inert aliases.Note — a compiler bug found and worked around
const X: fixed = 10.0is broken: aconstreference lowers to its raw integer value typedint(emit_call.ludicN_CONST), which silently corrupts fixed-point comparisons (I hit an infinite loop from it). The runtime uses inline fixed literals instead. Worth a separate fix so fixed consts are type-preserving.Wired end to end: parser splice trigger (
g_uses_numeric),emit_calldispatch, reseeded C-free seed, a self-asserting example (examples/library/numeric.ludic, 20 assertions, in the regression suite), per-symbol docs + sections + inventory. All suites green:x test84/84,x selfhost-test30/30 (golden renders byte-identical, bootstrap fixpoint holds),x test-tools30/30,check-impl/check-vocabulary/check-docs.Closing phase 5. With #52 / #54 / #55 done and phase 1 (#1), the type-system roadmap is now: shipped — 2D types (IVec2/Rect/Vector/Color), economy numbers (BigInt/Decimal), containers (Dict/Set), idle/polish numerics (Huge/Angle/Percent); remaining — the safety/control-flow types in #53 (option/result/tagged enums), which depend on real type-checking.