3 ms·
If you implement closures as thunks, you can just free them when done, no need for GC. closure int foo(int x) {return x + y;} int(*foo_p)(int) = malloc
by davidxa 16y ago
If you implement closures as thunks, you can just free them when done, no need for GC.
closure int foo(int x) {return x + y;}
int(*foo_p)(int) = malloc(sizeof(foo));
memcpy(foo_p,&foo,sizeof(foo));
return foo_p;
So, you can add working closures in one keyword (and possibly a special case for function pointer decay).