4 ms·
This looks like it doesn't share any context between cells, am I right? So I can't use functions defined in one cell in another.
by gh02t 9y ago
This looks like it doesn't share any context between cells, am I right? So I can't use functions defined in one cell in another.
- Mic92 9y agoThere exists a jupyter kernel for cling, which allows this (also this is C++ not C)
- atdt 9y agoYes, and it is quite good: https://github.com/root-project/cling#jupyter https://github.com/root-project/cling#jupyter I find it invaluable
- jasongrout 9y agoHere is another one in development: https://github.com/QuantStack/xeus-cling https://github.com/QuantStack/xeus-cling
- brendanrius 9y agoIt does not yet :)
- zokier 9y agoIt would be interesting exercise to compile cells into object files as they are entered and load them dynamically into a persistent process, doing needed linking etc on the fly in-memory. You'd also need to generate a header file from the current in-memory symbol table and implicitly include that in compilation. That might actually work relatively well for simple cases. But I imagine there would be a ton of problematic edge cases, considering that with C you can end up with all sorts of weird stuff.
- dgfgfdagasdfgfa 9y agoIf you protect it appropriately, you've basically re-implemented exec.
- williamstein 9y agoThe %cython mode for Sage notebooks (which I wrote in I think 2008??) does precisely that by generating a random-named Python shared object libary and importing it into the runnig Python process after each evaluation. There's a similar (%%cython?) mode for Jupyter notebooks.
- askvictor 9y agoHowever, every cell would need a main() function or it wouldn't do anything. Or you hold onto a main function from previous cells, perhaps overriding it, and make the notebook confusing as hell, defeating the point of notebooks