Is it possible to evaluate code with Sci and get back all the intermediate steps/forms the interpreter processed, along with results? For example, given something like:
(max (map inc (concat [1] [2])))
You would get:
[{:form "(concat [1] [2])" :val (1 2)}
{:form "(map inc (1 2))" :val (2 3)}
{:form "(max (2 3))" :val 3}]In an ideal world, I wouldn't want to make/maintain another interpreter when Sci works so well for so many use cases. At a very high level, if it makes sense, what would be the best way to add that kind of tracing capability to Sci?
Would it be a pretty invasive change? Or fairly easy to compose from existing capabilities? Or would I be better off rolling an interpreter from scratch?
what's the use case for this?
I don't think SCI is in a shape right now that you can easily do this, but perhaps tools.analyzer would be a better candidate
Use case is just a simple REPL trace utility.
or maybe even simpler: take the form, macroexpand-all and then you're left with only function calls and special forms, from there on, it should be pretty easy to rip it apart in the shape you like?
The idea being we decouple from std out, and since we get back data, we can send it anywhere we want. Perhaps to Portal. Or another tool.
also maybe take a look at #flow-storm which is a debugger which may do something along these lines
The hope was to avoid flow-storm since it patches the Clojure runtime.
ok yeah, well SCI actually is a runtime within a Clojure runtime which isn't 100% compatible with Clojure itself, so it's not going to work as a general REPL utility either
but I assume flow-storm is doing something with tools.analyzer to create these intermediate representations as well
Ah okay I see your point. Alright I'll take a look at tools.analyzer and re-evaluate flow-storm as well.
Thanks for the guidance. Appreciate it.
Not currently