3 ms·
Instead of putting all lines into one big chunk of code that is recompiled and rerun every time, one could instead compile it into a dynamic library with a sing
by yorwba 8y ago
Instead of putting all lines into one big chunk of code that is recompiled and rerun every time, one could instead compile it into a dynamic library with a single function that gets the current variable assignments passed as arguments, executes the single line of code and then waits for input to generate the next dynamic library, which it then loads and calls with the new variable assignment.
However, that solution would require the same level of language-specific knowledge as the modification mentioned below "Limitations" in the blog post. That's also why I never implemented the idea, despite having carried it around in my head for a few years now. Hopefully someone else will eventually get around to implementing it.
- pankajkumar229 8y agoCould it be done in llvm or another backend so all frontend languages can benefit?
- evmar 8y agoThis is how http://neugierig.org/software/c-repl/ http://neugierig.org/software/c-repl/ worked. (See "How it works" in the README: https://github.com/evmar/c-repl/blob/master/README https://github.com/evmar/c-repl/blob/master/README )
- rgoulter 8y agoI made use of ANTLR4 for parsing C to write a "worksheet" (like Swift's Playgrounds) tool: https://github.com/rgoulter/c-worksheet-instrumentor https://github.com/rgoulter/c-worksheet-instrumentor It's an example of what you can do with "specific to a language", although it'd suffer the same limitation of "slower after a big computation".
- dawg 8y agoThis approach is taken by https://github.com/dlang-community/drepl https://github.com/dlang-community/drepl and https://docs.scala-lang.org/overviews/repl/overview.html https://docs.scala-lang.org/overviews/repl/overview.html. While it works surprisingly well, you need to parse and transform the REPL input to emulate some language constructs in the right scope.