From e6fe2dfd81153a1207729835ac6a8097e75b2f16 Mon Sep 17 00:00:00 2001 From: Brummel Date: Sat, 9 May 2026 22:51:17 +0200 Subject: [PATCH] =?UTF-8?q?iter=2022-tidy.1:=20DESIGN.md=20=E2=80=94=20rec?= =?UTF-8?q?oncile=20Decision=2011=20with=20milestone-22=20outcome=20(no=20?= =?UTF-8?q?Prelude,=20'=5F=5F'=20separator)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/DESIGN.md | 73 +++++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/docs/DESIGN.md b/docs/DESIGN.md index f556158..2938377 100644 --- a/docs/DESIGN.md +++ b/docs/DESIGN.md @@ -1724,46 +1724,59 @@ axis-5 (kind `*` only) covers the space. ### Prelude (built-in) classes -22a/22b ship a fixed Prelude consisting of three classes: **`Show`, -`Eq`, `Ord`**, with instances for the four primitive types `Int`, -`Float`, `Bool`, `String`. `Ord` declares `Eq` as its superclass. +Milestone 22 ships **no built-in Prelude classes**. The original +22a draft committed to a fixed Prelude (Show / Eq / Ord on the +primitives), but the implementation work to wire `int_to_str` as a +heap-allocated-string runtime primitive proved substantively +separable from the typeclass machinery itself, and the LLM-utility +case for primitive `Show` is weak (LLM-natural form is `int_to_str +x`, not `show x` through a single-instance class). The user-class +end-to-end path is the milestone's typeclass acceptance gate +(22c's `class Foo a` + `data IntBox` + `instance Foo IntBox` +fixture); see `docs/specs/2026-05-09-22-typeclasses.md` +"Amendments" §"22b.4b dropped" for the substantive rationale. -`print x` is rewired through `Show.show`: at codegen, the existing -print primitive routes its argument through the resolved `show@T`. -This is the one operator-routing change in 22b. +A future milestone may add a Prelude when concrete LLM-author code +surfaces a case that benefits from `Show a` / `Eq a` / `Ord a` +over per-type primitive functions. Until then, primitive output +goes through `io/print_int` / `io/print_bool` / `io/print_str` +directly. -`==`, `<`, `<=`, `>`, `>=` REMAIN primitive operators. Class methods -are accessed by name (`eq x y`, `lt x y`, …), not via these operators. -Routing operators through classes is deliberately deferred — it would -require migrating every existing fixture and would risk firing the -bench gate. A future iteration may add operator routing once the -typeclass layer has settled and the bench corpus is stable. +`==`, `<`, `<=`, `>`, `>=` REMAIN primitive operators (unchanged +from the 22a draft). Class methods are accessed by name (`eq x y`, +`lt x y`, …), not via these operators. Routing operators through +classes is deliberately deferred — it would require migrating every +existing fixture and would re-baseline the bench corpus, which is a +new-baseline decision rather than an iter detail. -`Num` is NOT in the 22a/22b Prelude. Arithmetic operators (`+`, `-`, -`*`, `/`) stay primitive and per-type. The LLM-natural pattern of -distinct `Int` and `Float` arithmetic is preserved; class-based -numeric overloading would invoke literal-defaulting which axis-7 -already excluded. +`Num` is NOT in milestone 22. Arithmetic operators (`+`, `-`, `*`, +`/`) stay primitive and per-type. Class-based numeric overloading +would invoke literal-defaulting which axis-7 already excluded. ### What this decision does NOT commit to -- **Operator routing.** `==`, `<`, etc. stay primitive in 22a/22b. - Class-routing operators is a future-iteration option, not a +- **Operator routing.** `==`, `<`, etc. stay primitive in milestone + 22. Class-routing operators is a future-iteration option, not a Decision-11 commitment. - **Form-B (prose) projection of class/instance.** The prose - renderer for the new schema nodes is 22b implementer scope; the - form is not pinned in 22a. -- **Specific monomorphised-symbol naming format.** The naming is - deterministic from `(method, type-hash)`; the exact textual form - is fixed in 22b alongside the existing mangling scheme. + renderer for the new schema nodes is one-way (no parser by + design) and was deferred from milestone 22 entirely; the + placeholder render in `crates/ailang-prose/src/lib.rs` is + informational only. A future iter ships the full prose + projection if/when prose-side authoring needs surface. +- **Specific monomorphised-symbol naming format.** Milestone 22 + uses `__` for primitive type targets + (e.g. `show__Int`) and `__<8-hex-prefix>` for compound + types (where `<8-hex-prefix>` is the BLAKE3 hash of the canonical + type bytes). The `__` separator was chosen over `#` and `@` for + LLVM IR identifier legality. - **Mode annotations on class methods.** Class method signatures ARE full FnSigs and DO carry mode annotations per Decision 10; - the convention for default modes (typically `borrow` for - read-only methods like `show`, `eq`) is settled in 22b. -- **Number of Prelude classes.** Three classes (Show, Eq, Ord) is - the 22b commitment. Adding `Num`, `Functor`-substitutes - (per-type), or domain-specific classes is gated on the Feature- - acceptance criterion at the time of proposal. + the convention is `borrow` for read-only methods. User-defined + classes pick modes per method. +- **Number of Prelude classes.** Milestone 22 ships zero (no + Prelude). A future Prelude milestone gates class additions on + the Feature-acceptance criterion at the time of proposal. ## Mangling scheme (Iter 5c)