iter 22-tidy.1: DESIGN.md — reconcile Decision 11 with milestone-22 outcome (no Prelude, '__' separator)

This commit is contained in:
2026-05-09 22:51:17 +02:00
parent a98da81e32
commit e6fe2dfd81
+43 -30
View File
@@ -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 `<method>__<type-surface-name>` for primitive type targets
(e.g. `show__Int`) and `<method>__<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)