FFI & callbacks =============== There are at least 4 cases: * SLUL calling C (and potentially calling SLUL again) * C calling SLUL (and potentially calling C again) * C starting SLUL code (potentially calling C again) * SLUL starting C code (potentially calling SLUL again) Problems: * Passing "user_pointers" back - what if there are nested calls in several layers? use the latest/"topmost" one? * Givemes * Function coloring - pure vs mutable vs I/O - asynchronous vs synchronous - async-cancellable vs not * Exceptions / synchronous errors in callbacks * Asynchronous errors/termination in callbacks User pointers, Givemes ---------------------- Require that all C code passes: - a "context" parameter (for the SLUL code) - a "user_param" parameter (for any C callbacks) Require that SLUL callbacks work through services/entrys? - the C code would indirectly (via the SLUL runtime or similar, possibly via some context parameter) provide the givemes. Function coloring, Exceptions in callbacks ------------------------------------------ TODO. Some ideas: * Run C code out-of-process (slow) * Provide a virtual implementation of the libc (hard, but fast) * Proxy some libc functions: - do special things on exit(), signal(), etc? - track resources? - track I/O? Maybe calling C code should be completely forbidden in pure functions? Or: * Run C code in an emulator(!) (very slow) * Run C code with a fully virtual libc (slow, hard) - it must be unable to write to SLUL memory - it must be unable to do anything to the OS - it's internal state must be copy-on-write - and changes discarded on return to SLUL (but only the topmost "layer", in case of nested callbacks)