4 ms·
I don't think monkey patching is required. Although without a dedicated interpreter, you can just do what sbcl does under the hood and maintain what is essentia
by emidln 6y ago
I don't think monkey patching is required. Although without a dedicated interpreter, you can just do what sbcl does under the hood and maintain what is essentially a tempfile and keep compiling that and reporting the output for every new line/block of code. (I don't know how sbcl actually works, being a lisp I presume it doesn't actually use a tempfile but instead a list in memory of the code the user submitted and then invokes the compiler as needed for new input including the output state as available symbols.)
A cycle that went something like:
1. Write the line to a file
2. Compile file with default flags
3. Run binary in gdb causing gdb to dump certain interest info (stack info, variable contents, etc)
4. Read the sections/symbols and merge this data into the gdb data (maybe get it from gdb)
5. Dump this data into your reply and refresh waiting for user input.
You could have a few basic commands in the repl:
Modify the compiler args
Add/remove/edit a line
Attach gdb.
Emacs or vim could easily do this, and I suspect there are people who already do almost exactly this.
You could also just use any editor/ide with debug integration and keep a scratch file around...
- capableweb 6y ago> I don't think monkey patching is required We're talking about a repl here, not just a basic shell. You'll need to be able to redefine functions and everything else at runtime so a repl is all you need to run your program. A lisp with a standard repl is running miles around any editor/ide with debugger support, as the workflow with repls, especially ones that can nest on exception and so on, is much faster.