In programming languages, a closure is a function or reference to a function together with a referencing environment—a table storing a reference to each of the non-local variables (also called free variables or upvalues) of that function.
struct__main_block_impl_0{struct__block_implimpl;struct__main_block_desc_0*Desc;inta;__main_block_impl_0(void*fp,struct__main_block_desc_0*desc,int_a,intflags=0):a(_a){impl.isa=&_NSConcreteStackBlock;impl.Flags=flags;impl.FuncPtr=fp;Desc=desc;}};staticvoid__main_block_func_0(struct__main_block_impl_0*__cself){inta=__cself->a;// bound by copyprintf("%d\n",a);}staticstruct__main_block_desc_0{size_treserved;size_tBlock_size;}__main_block_desc_0_DATA={0,sizeof(struct__main_block_impl_0)};intmain(){inta=100;void(*block2)(void)=(void(*)())&__main_block_impl_0((void*)__main_block_func_0,&__main_block_desc_0_DATA,a);((void(*)(__block_impl*))((__block_impl*)block2)->FuncPtr)((__block_impl*)block2);return0;}
struct__Block_byref_i_0{void*__isa;__Block_byref_i_0*__forwarding;int__flags;int__size;inti;};struct__main_block_impl_0{struct__block_implimpl;struct__main_block_desc_0*Desc;__Block_byref_i_0*i;// by ref__main_block_impl_0(void*fp,struct__main_block_desc_0*desc,__Block_byref_i_0*_i,intflags=0):i(_i->__forwarding){impl.isa=&_NSConcreteStackBlock;impl.Flags=flags;impl.FuncPtr=fp;Desc=desc;}};staticvoid__main_block_func_0(struct__main_block_impl_0*__cself){__Block_byref_i_0*i=__cself->i;// bound by refprintf("%d\n",(i->__forwarding->i));(i->__forwarding->i)=1023;}staticvoid__main_block_copy_0(struct__main_block_impl_0*dst,struct__main_block_impl_0*src){_Block_object_assign((void*)&dst->i,(void*)src->i,8/*BLOCK_FIELD_IS_BYREF*/);}staticvoid__main_block_dispose_0(struct__main_block_impl_0*src){_Block_object_dispose((void*)src->i,8/*BLOCK_FIELD_IS_BYREF*/);}staticstruct__main_block_desc_0{size_treserved;size_tBlock_size;void(*copy)(struct__main_block_impl_0*,struct__main_block_impl_0*);void(*dispose)(struct__main_block_impl_0*);}__main_block_desc_0_DATA={0,sizeof(struct__main_block_impl_0),__main_block_copy_0,__main_block_dispose_0};intmain(){__attribute__((__blocks__(byref)))__Block_byref_i_0i={(void*)0,(__Block_byref_i_0*)&i,0,sizeof(__Block_byref_i_0),1024};void(*block1)(void)=(void(*)())&__main_block_impl_0((void*)__main_block_func_0,&__main_block_desc_0_DATA,(__Block_byref_i_0*)&i,570425344);((void(*)(__block_impl*))((__block_impl*)block1)->FuncPtr)((__block_impl*)block1);return0;}