Let me do an UP on this thread. @stisa Having a context between the code blocks looks like a non-trivial and very useful task. Did you make any progress? Can I jump in?
A little background: I did some experiments half a year ago. I was able to call a function from Nim. The binary was running, it was looking for a _test.nim_ file to change, then it compiled it to an _.so_ file, dynamically loaded it, and called the function. This was in a loop, so every time I changed the _test.nim_ file, it compiled, loaded, and run it. I'm not saying this is the perfect solution, but we could generate code, we can access _locals()_, we can pass any parameters, etc. So the child process could access the parent process' variables. It is not easy, but looks doable to me. Peter