jupyter-c-kernel
jupyter-c-kernel copied to clipboard
Make it possible to split implementation over multiple cells
Currently each cell should contain an entire functional c program. Notebooks would be much more descriptive if you could incrementally build up a program and intermix functions and markdown.
- Markdown cell with some explanation
- Code cell with a function
- Markdown cell with some more explanation
- Code cell with another function
- Markdown cell with even more explanation
- Code cell with main function calling other two functions
That would be a good improvement, anyone wants to open a PR for this?
For basic implementation (without redefining functions), changes needed probably:
- Concatenate all
codefrom cells (store all cells in mem when enteringdo_execute) --> Maybe there is a Jupyter notebook provided way/feature to do this?- But how to see if the first cell was changed and re-executed?
- Not complain (just don't call anything) when there is no
usermainfound from master.c https://github.com/brendan-rius/jupyter-c-kernel/blob/45616068bc409b8aa6b9cda5e4a8072b98a12330/resources/master.c#L23-L27
There is also relevant stackoverflow question about a accumilating mechanism: https://stackoverflow.com/questions/43316613/access-jupyter-code-cell-metadata-in-a-kernel
I think there's a better way to do this:
- Implement the
.cper each notebook, instead of each cell in the previous C kernel - Whenever you enter the cell, extend the code at the backend between the
main()Note: It's pretty hard implementation because of the conflict with all functions (maybe, I just think about it a few mins ago)
- When you run the code in each cell, it will only append the old code.
Is there any additional way? This topic requires lots of discussion to be finished this.