a capturing closure transpiles to a fat-pair value (state+function) and the captured local is accessed via the state. lambda should also cast the generic pointer to the known state type. <<< main = fun () { var bump int = 10 var f fun (i int) int = fun (i int) int { return i + bump } var r int = f(5) } >>> #include "core.c" struct __cat_type_0 { void* state; integer (*call)(void* state, integer); }; struct __cat_type_1; struct __cat_type_1 { integer* bump; }; void catskill_main(void); integer __cat_lambda_0(void* state_void, integer i); void catskill_main(void) { integer bump = 10; struct __cat_type_0 f = (struct __cat_type_0){ .state = &(struct __cat_type_1){ .bump = &bump }, .call = __cat_lambda_0 }; integer r = f.call(f.state, 5); } integer __cat_lambda_0(void* state_void, integer i) { struct __cat_type_1* state = state_void; return i + (*state->bump); } #include "runtime.c"