Files
sx/examples/97-objc-block-inline.sx
2026-05-18 17:40:10 +03:00

20 lines
482 B
Plaintext

// `xx <closure>` passed as a `*Block` fn argument auto-allocates the
// Block instance and passes its address — no named temp required.
// Matches the ergonomics of ObjC's `^{...}` literal at the call site.
#import "modules/std.sx";
#import "modules/std/objc_block.sx";
invoke_once :: (b: *Block) {
invoke_fn : (*Block) -> void = xx b.invoke;
invoke_fn(b);
}
main :: () -> s32 {
x : s64 = 7;
invoke_once(xx () => {
print("inline block, x = {}\n", x);
});
0;
}