jupyter-c-kernel icon indicating copy to clipboard operation
jupyter-c-kernel copied to clipboard

Make it possible to split implementation over multiple cells

Open spoorcc opened this issue 8 years ago • 4 comments
trafficstars

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

spoorcc avatar Apr 13 '17 15:04 spoorcc

That would be a good improvement, anyone wants to open a PR for this?

brendan-rius avatar Aug 10 '17 12:08 brendan-rius

For basic implementation (without redefining functions), changes needed probably:

  • Concatenate all code from cells (store all cells in mem when entering do_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 usermain found from master.c https://github.com/brendan-rius/jupyter-c-kernel/blob/45616068bc409b8aa6b9cda5e4a8072b98a12330/resources/master.c#L23-L27

spoorcc avatar Aug 10 '17 14:08 spoorcc

There is also relevant stackoverflow question about a accumilating mechanism: https://stackoverflow.com/questions/43316613/access-jupyter-code-cell-metadata-in-a-kernel

spoorcc avatar Sep 22 '17 07:09 spoorcc

I think there's a better way to do this:

  1. Implement the .c per each notebook, instead of each cell in the previous C kernel
  2. 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)

  3. 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.

shiroinekotfs avatar Aug 15 '23 02:08 shiroinekotfs