Closed felixSchl closed 6 years ago
I am not sure if this is desirable now. Having blocks makes writing curried FFI functions a breeze and the overhead (apart from losing compiler compatibility) is negligible from what I can tell.
An alternative, however, could be revisiting to use C++ for the closures feature alone, and otherwise pretend we're in C. That should keep the simplicity and perhaps improve on compatibility with different compiler toolchains.
Implemented!
Currently we rely on a clang extension called "Blocks" contributed to the compiler project by Apple that essentially gives us closures in C. It would be interesting to see if we can go without this extension in order to be able to compile without clang and to avoid the blocks runtime.
It should be possible to - at compile time - inspect each function's scope, create a struct for it, and model functions like this: