plan(reify): re-architect onto declare/define as the only compiler primitive
User-directed redirection. The compiler should expose ONLY declare() and
define(handle, info) as comptime type-table primitives; reify / make_enum /
RecvResult / TryResult all become plain sx in meta.sx (reify ==
{ h := declare(); define(h, info); return h; }). The AST-walking reifyType
and every syntactic reify recognition (decl.zig E :: reify hook, generic.zig
findReturnReifyCall routing) are to be DELETED, replaced by generic comptime
evaluation of a Type-returning expression.
PLAN-REIFY gains a RE-ARCHITECTURE section: the irreducible compiler floor
(declare = empty nominal slot; define = decode a TypeInfo VALUE + fill via
updatePreservingKey; comptime-eval a Type-returning ::-RHS/type-fn body),
the resolved naming/identity story (declare mints anonymous, the binding site
names it; identity via the existing instantiation cache), and an F1-F5 phase
table that re-greens 0614/0615/0617 on the floor.
No code change in this commit — the in-session Phase 3.2 attempt (make_enum +
eval-decode reader) was reverted (reset to 9306ad5) so the floor is built
first. Checkpoint records the revert + sets next step = F1.
This commit is contained in:
@@ -12,9 +12,9 @@ result types are pure sx library code. `examples/0617` green (both construct +
|
||||
match, incl. payload-less `.closed`/`.empty`). Full suite green (673 examples).
|
||||
Cadence: 3.0 xfail (undefined → RED) → 3.1 green.
|
||||
|
||||
**`make_enum(variants)` NOT done** (Phase 3.2): it takes a RUNTIME `[]EnumVariant`,
|
||||
so `reify(.enum(.{ variants = variants }))` is a non-literal arg — blocked on the
|
||||
generalized reify reader (pairs with 2.2). **`type_info` NOT done** (Phase 2.2).
|
||||
**Phase 3.1 is the last GREEN step.** Phase 3.2 was attempted + reverted; the stream
|
||||
now pivots to the `declare`/`define` RE-ARCHITECTURE (see the section below + the
|
||||
F1–F5 table in PLAN-REIFY). **`type_info` NOT done** (old Phase 2.2, orthogonal).
|
||||
|
||||
### (prior) Phase 2.1 (green) — `field_type` done. `field_type($T, i) -> Type` is
|
||||
implemented over the type table (`fieldTypeOf` in `lower/generic.zig`, re-exported
|
||||
@@ -90,20 +90,35 @@ type table and shifts every `.ir` snapshot (broke 37 examples in a trial). An
|
||||
on-demand import keeps the prelude clean; reify users `#import
|
||||
"modules/std/meta.sx"`. (User-directed.)
|
||||
|
||||
## Next step
|
||||
Two pending pieces, both blocked on the SAME thing — **a generalized reify reader**
|
||||
(`reifyType` currently AST-walks a LITERAL `TypeInfo`; it can't read a computed /
|
||||
variable `TypeInfo`). Do that generalization (interp-evaluate the `TypeInfo` value,
|
||||
or a broader AST reader) and both unlock:
|
||||
- **Phase 3.2 — `make_enum(variants: []EnumVariant) -> Type`** (sx lib; `variants` is
|
||||
a runtime value, not a literal).
|
||||
- **Phase 2.2 — `type_info($T) -> TypeInfo`** (reflect → a `TypeInfo` value; also
|
||||
needs the `TypeInfo` data model widened past `` `enum `` for struct/tuple). Bails
|
||||
loudly today in `call.zig:tryLowerReflectionCall`.
|
||||
## RE-ARCHITECTURE in progress (user-directed, 2026-06-16)
|
||||
**`declare`/`define` are to be the ONLY compiler primitives; `reify` / `make_enum` /
|
||||
`RecvResult` / `TryResult` move to sx in `meta.sx`.** `reify` becomes literally
|
||||
`{ h := declare(); define(h, info); return h; }`. The AST-walking `reifyType` and all
|
||||
syntactic `reify` recognition (`decl.zig` `E :: reify` hook, `generic.zig`
|
||||
`findReturnReifyCall`) get DELETED, replaced by generic comptime evaluation of a
|
||||
Type-returning expression. Full F1–F5 phase table + the resolved naming/identity
|
||||
design is in **PLAN-REIFY.md → "RE-ARCHITECTURE"**.
|
||||
|
||||
Remaining after that: **Phase 4** (self-reference via `declare()`/`define()` — API
|
||||
already decided), **Phase 5** (validation + loud diagnostics: dup variants, bad
|
||||
backing, by-value self-ref). Both are independent of the reader generalization.
|
||||
**A Phase 3.2 attempt (make_enum + an eval-decode reader, `reifyEnumFromVariantsValue`
|
||||
+ `reifyValueFn`) was implemented this session, then REVERTED** (`git reset --hard
|
||||
9306ad5`) per this decision — the reader grew the compiler instead of shrinking it.
|
||||
The eval-decode *decode logic* is salvage for `define` (see commit 4d6c463 in reflog
|
||||
if needed); the *syntactic routing* is discarded.
|
||||
|
||||
## Next step
|
||||
**F1 — `declare()`/`define()` primitives + a directly-minted RECURSIVE enum.**
|
||||
- `declare() -> Type`: intern an empty forward nominal slot (`reserveShadowEnumSlot`
|
||||
shape, `nominal.zig:98`), anonymous, return a first-class `Type`.
|
||||
- `define(handle, info)`: decode the `TypeInfo` *value* (reuse the reverted decode:
|
||||
interp `Value` → names + payload `Type`-tags → `tagged_union` matching
|
||||
`buildEnumInfo`), fill via `updatePreservingKey`.
|
||||
- `X :: declare()` decl hook + scan-time `define(...)` side-effect (must complete
|
||||
before codegen needs the layout — same scan-time window the old `reifyType` used).
|
||||
- Example: `List :: declare(); define(List, .enum(.{ … payload = *List … }))` —
|
||||
cons/nil list, construct + match. Self-ref works because the handle predates the body.
|
||||
Then F2 (reify→sx + general comptime-Type-decl eval, delete `reifyType`), F3 (type-fn
|
||||
body eval, delete `findReturnReifyCall`, re-green 0615/0617), F4 (make_enum in sx),
|
||||
F5 (validation). `type_info` (old 2.2) stays orthogonal/pending.
|
||||
|
||||
### (superseded) earlier Next step — `type_info` value construction Reflect a type into a `TypeInfo`
|
||||
*value* — the inverse of reify. Two sub-pieces, both non-trivial: (a) widen the
|
||||
|
||||
Reference in New Issue
Block a user