When I read about C++ modules, I thought it could be used for dynamically adding code snippets and testing the code in a REPL environment.
The next step was to search the web, and sure enough I found out about xeus-cling.
If I understand correctly Cling makes use of Clang and should be able to support all the C++ features supported by Clang. I tried reading about cling & xeus-cling’s architecture, and it seems that cling is maintaining an AST of the code, adding wrappers when needed, and performing lowering, translation to LLVM’s IR and compilation to native code (much like the Julia language).
I thought that since compilation of modules is extremely quick, a C++ REPL could quickly compile individual cells with class/function definitions linking a dynamic library which would be
dlopened by the REPL. Global variables would be stored in a
map<string, any> and referenced by the REPL.
Naturally, this is only a rough sketch, but I would like to hear comments regarding the pros and cons of this approach.
BTW, kernel installation would be much simpler as it relies on standard C++ compilers, and it would alleviate certain obscure error messages (I ran into a few “function definition is not allowed here” and other error messages due to previous cells during my short experience with xeus-cling)