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.
39 lines
1.3 KiB
Plaintext
39 lines
1.3 KiB
Plaintext
// Comptime type construction — channel result types: RecvResult($T) /
|
|
// TryResult($T), built ENTIRELY in sx library code as type-fns over the
|
|
// `define(declare(), ...)` primitives (no compiler machinery). A blocking recv
|
|
// yields a value or a `closed` marker; a non-blocking try-recv adds `empty` —
|
|
// three states a bool can't express. This locks that they construct and match
|
|
// like any enum, and that `RecvResult(i64)` is one nominal type across sites
|
|
// (the type-fn identity path).
|
|
#import "modules/std.sx";
|
|
#import "modules/std/meta.sx";
|
|
|
|
main :: () -> i32 {
|
|
r := RecvResult(i64).value(42);
|
|
if r == {
|
|
case .value: (v) { print("recv value {}\n", v); }
|
|
case .closed: { print("recv closed\n"); }
|
|
}
|
|
|
|
rc : RecvResult(i64) = .closed;
|
|
if rc == {
|
|
case .value: (v) { print("recv value {}\n", v); }
|
|
case .closed: { print("recv closed\n"); }
|
|
}
|
|
|
|
t := TryResult(i64).value(7);
|
|
if t == {
|
|
case .value: (v) { print("try value {}\n", v); }
|
|
case .empty: { print("try empty\n"); }
|
|
case .closed: { print("try closed\n"); }
|
|
}
|
|
|
|
te : TryResult(i64) = .empty;
|
|
if te == {
|
|
case .value: (v) { print("try value {}\n", v); }
|
|
case .empty: { print("try empty\n"); }
|
|
case .closed: { print("try closed\n"); }
|
|
}
|
|
return 0;
|
|
}
|