sci

Steven Lombardi 2024-06-23T23:05:47.285459Z

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}]

Steven Lombardi 2024-06-25T17:11:03.382549Z

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?

Steven Lombardi 2024-06-25T17:13:39.492759Z

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?

borkdude 2024-06-25T17:16:31.804719Z

what's the use case for this?

borkdude 2024-06-25T17:17:22.966719Z

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

Steven Lombardi 2024-06-25T17:18:09.965679Z

Use case is just a simple REPL trace utility.

borkdude 2024-06-25T17:18:37.985119Z

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?

Steven Lombardi 2024-06-25T17:18:58.002469Z

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.

borkdude 2024-06-25T17:19:00.165159Z

also maybe take a look at #flow-storm which is a debugger which may do something along these lines

Steven Lombardi 2024-06-25T17:19:33.969119Z

The hope was to avoid flow-storm since it patches the Clojure runtime.

borkdude 2024-06-25T17:20:18.852409Z

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

borkdude 2024-06-25T17:21:06.899269Z

but I assume flow-storm is doing something with tools.analyzer to create these intermediate representations as well

Steven Lombardi 2024-06-25T17:23:46.943379Z

Ah okay I see your point. Alright I'll take a look at tools.analyzer and re-evaluate flow-storm as well.

Steven Lombardi 2024-06-25T17:24:29.739789Z

Thanks for the guidance. Appreciate it.

👍 1
borkdude 2024-06-24T06:34:22.939379Z

Not currently

👍 1