Files
sx/examples/0614-comptime-metatype-enum.sx
agra 12e2ff7ef4 docs+rename: erase the reify name everywhere — stream is METATYPE
The compiler concept is declare/define (comptime type construction); the
old "reify" framing is gone from the entire repo.

- Rename: PLAN-REIFY → PLAN-METATYPE, CHECKPOINT-REIFY → CHECKPOINT-METATYPE,
  PLAN-POST-REIFY → PLAN-POST-METATYPE (both rewritten around declare/define);
  examples 0614/0615/0617 → comptime-metatype-* (+ their expected/ triplets),
  headers rewritten.
- Scrub reify from design/execution-evolution-roadmap.md (§7 step 3 contracts,
  §8.1, §9 decisions, §10 gates) → declare/define / comptime type construction.
- core.sx prelude pointer + parser.test.zig surface lock updated to the
  declare/define builtins (define(handle, info) -> Type; EnumInfo.name).

No behavior change; renamed examples match their renamed snapshots. Full
suite green (673), all unit tests pass. Zero `reify` tokens remain in
src/docs/sx/examples.
2026-06-16 21:23:05 +03:00

31 lines
1.0 KiB
Plaintext

// Comptime type construction: mint a NEW nominal enum from a `TypeInfo` value
// via the `define(declare(), info)` primitives, then construct one of its
// variants and match on it — exercising that a programmatically-built enum
// (with NO backing AST decl) flows through enum codegen unmodified (layout /
// construct / match), byte-identical to a hand-written enum.
//
// The enum has two variants: `value` carrying an i64 payload, and `closed` with
// no payload (`payload = void`).
#import "modules/std.sx";
#import "modules/std/meta.sx";
E :: define(declare(), .enum(.{ name = "E", variants = .[
EnumVariant.{ name = "value", payload = i64 },
EnumVariant.{ name = "closed", payload = void },
] }));
main :: () -> i32 {
e := E.value(3);
if e == {
case .value: (v) { print("value {}\n", v); }
case .closed: { print("closed\n"); }
}
c : E = .closed;
if c == {
case .value: (v) { print("value {}\n", v); }
case .closed: { print("closed\n"); }
}
return 0;
}