// A capturing closure rides through `xx ... : Block` and the
// captured state survives across the call. The block's sx_env field
// holds the closure's env pointer; the invoke trampoline restores it
// before delegating.

#import "modules/std.sx";
#import "modules/std/objc_block.sx";

main :: () -> s32 {
  x : s64 = 42;
  y : s64 = 100;
  cl := () => { print("x + y = {}\n", x + y); };
  b : Block = xx cl;
  invoke_fn : (*Block) -> void callconv(.c) = xx b.invoke;
  invoke_fn(@b);
  0;
}
