iter 22-tidy.1: DESIGN.md — reconcile Decision 11 with milestone-22 outcome (no Prelude, '__' separator)
This commit is contained in:
+43
-30
@@ -1724,46 +1724,59 @@ axis-5 (kind `*` only) covers the space.
|
|||||||
|
|
||||||
### Prelude (built-in) classes
|
### Prelude (built-in) classes
|
||||||
|
|
||||||
22a/22b ship a fixed Prelude consisting of three classes: **`Show`,
|
Milestone 22 ships **no built-in Prelude classes**. The original
|
||||||
`Eq`, `Ord`**, with instances for the four primitive types `Int`,
|
22a draft committed to a fixed Prelude (Show / Eq / Ord on the
|
||||||
`Float`, `Bool`, `String`. `Ord` declares `Eq` as its superclass.
|
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
|
A future milestone may add a Prelude when concrete LLM-author code
|
||||||
print primitive routes its argument through the resolved `show@T`.
|
surfaces a case that benefits from `Show a` / `Eq a` / `Ord a`
|
||||||
This is the one operator-routing change in 22b.
|
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
|
`==`, `<`, `<=`, `>`, `>=` REMAIN primitive operators (unchanged
|
||||||
are accessed by name (`eq x y`, `lt x y`, …), not via these operators.
|
from the 22a draft). Class methods are accessed by name (`eq x y`,
|
||||||
Routing operators through classes is deliberately deferred — it would
|
`lt x y`, …), not via these operators. Routing operators through
|
||||||
require migrating every existing fixture and would risk firing the
|
classes is deliberately deferred — it would require migrating every
|
||||||
bench gate. A future iteration may add operator routing once the
|
existing fixture and would re-baseline the bench corpus, which is a
|
||||||
typeclass layer has settled and the bench corpus is stable.
|
new-baseline decision rather than an iter detail.
|
||||||
|
|
||||||
`Num` is NOT in the 22a/22b Prelude. Arithmetic operators (`+`, `-`,
|
`Num` is NOT in milestone 22. Arithmetic operators (`+`, `-`, `*`,
|
||||||
`*`, `/`) stay primitive and per-type. The LLM-natural pattern of
|
`/`) stay primitive and per-type. Class-based numeric overloading
|
||||||
distinct `Int` and `Float` arithmetic is preserved; class-based
|
would invoke literal-defaulting which axis-7 already excluded.
|
||||||
numeric overloading would invoke literal-defaulting which axis-7
|
|
||||||
already excluded.
|
|
||||||
|
|
||||||
### What this decision does NOT commit to
|
### What this decision does NOT commit to
|
||||||
|
|
||||||
- **Operator routing.** `==`, `<`, etc. stay primitive in 22a/22b.
|
- **Operator routing.** `==`, `<`, etc. stay primitive in milestone
|
||||||
Class-routing operators is a future-iteration option, not a
|
22. Class-routing operators is a future-iteration option, not a
|
||||||
Decision-11 commitment.
|
Decision-11 commitment.
|
||||||
- **Form-B (prose) projection of class/instance.** The prose
|
- **Form-B (prose) projection of class/instance.** The prose
|
||||||
renderer for the new schema nodes is 22b implementer scope; the
|
renderer for the new schema nodes is one-way (no parser by
|
||||||
form is not pinned in 22a.
|
design) and was deferred from milestone 22 entirely; the
|
||||||
- **Specific monomorphised-symbol naming format.** The naming is
|
placeholder render in `crates/ailang-prose/src/lib.rs` is
|
||||||
deterministic from `(method, type-hash)`; the exact textual form
|
informational only. A future iter ships the full prose
|
||||||
is fixed in 22b alongside the existing mangling scheme.
|
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
|
- **Mode annotations on class methods.** Class method signatures
|
||||||
ARE full FnSigs and DO carry mode annotations per Decision 10;
|
ARE full FnSigs and DO carry mode annotations per Decision 10;
|
||||||
the convention for default modes (typically `borrow` for
|
the convention is `borrow` for read-only methods. User-defined
|
||||||
read-only methods like `show`, `eq`) is settled in 22b.
|
classes pick modes per method.
|
||||||
- **Number of Prelude classes.** Three classes (Show, Eq, Ord) is
|
- **Number of Prelude classes.** Milestone 22 ships zero (no
|
||||||
the 22b commitment. Adding `Num`, `Functor`-substitutes
|
Prelude). A future Prelude milestone gates class additions on
|
||||||
(per-type), or domain-specific classes is gated on the Feature-
|
the Feature-acceptance criterion at the time of proposal.
|
||||||
acceptance criterion at the time of proposal.
|
|
||||||
|
|
||||||
## Mangling scheme (Iter 5c)
|
## Mangling scheme (Iter 5c)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user