Files
sx/examples/0504-packs-pack-impl-match.sx
agra 12bf61a9fc std: restructure step 3 — ffi/ moves, build.sx, math dir spelling, fixtures
- objc.sx, objc_block.sx (from std/) + sdl3/opengl/raylib/stb/stb_truetype/
  wasm vendor bindings (from modules/ root) -> modules/ffi/
- std/uikit.sx deleted: platform/uikit.sx already declares UIApplicationMain
  and imports objc; '#framework "UIKit"' cannot live in a file imported on
  macOS targets (unconditional link directive, UIKit is iOS-only), so the
  three iOS-only examples carry the 3-line glue inline. 1607/1608/1616 also
  un-rotted (dead ns_string -> 'xx "..."' Into conversions, callconv(.c)
  msgSend fn-ptrs) — all three build for ios-sim/ios again.
- math/math.sx -> math/scalar.sx; one spelling '#import "modules/math"'
  everywhere (4 pinned IR snapshots regenerated: dir import adds Vec2/Mat4
  to the type tables).
- compiler.sx -> build.sx (imports, CLAUDE.md bundling table, specs.md).
- testpkg/ + test_c.sx -> tests/fixtures/ (resolve CWD-relative from repo
  root, same as vendors/).
- library-internal imports use full modules/... paths (std.sx tail,
  platform/bundle.sx, fixtures).
2026-06-11 08:37:22 +03:00

47 lines
1.6 KiB
Plaintext

// Variadic heterogeneous type packs — `..$args` — impl matching
// lock-in.
//
// Step 1d slice for the pack feature (see
// ~/.claude/plans/lets-see-options-for-merry-dijkstra.md). Pins
// today's concrete-only impl-matching behaviour: a user-declared
// `impl Into(Block) for Closure(..$args) -> $R` does NOT match
// any concrete closure source type. The xx cast site hits the
// existing "no `Into(Block) for <src>` impl" diagnostic even
// though the pack impl is reachable.
//
// Next commit (1d.B) teaches `tryUserConversion` /
// `registerParamImpl` to walk a second `param_impl_pack_map`
// when the concrete-key miss happens. Pack impls bind their
// `$args` and `$R` to the concrete source closure's tail types
// and return; monomorphisation proceeds against those bindings.
//
// The `Closure(s32, bool) -> bool` shape is not covered by
// stdlib's hand-rolled impls (only `Closure() -> void` and
// `Closure(bool) -> void`) and not covered by 96-block-multi-arg's
// `Closure(s32, *void) -> void` impl, so the pack impl is the
// only candidate.
#import "modules/std.sx";
#import "modules/ffi/objc_block.sx";
impl Into(Block) for Closure(..$args) -> $R {
convert :: (self: Closure(..$args) -> $R) -> Block {
.{
isa = @_NSConcreteStackBlock,
flags = 0,
reserved = 0,
invoke = null,
descriptor = xx @__sx_block_descriptor,
sx_env = self.env,
sx_fn = self.fn_ptr,
}
}
}
main :: () -> s32 {
cl := (a: s32, b: bool) => true;
b : *Block = xx cl;
print("pack impl match ok\n");
return 0;
}