Quick question about sci.core/ns . If I eval an expression that changes the namespace, such as (ns foo) , should that information be available in sci.core/ns? Given what I'm seeing for the https://github.com/babashka/babashka.nrepl/blob/master/src/babashka/nrepl/impl/server.clj#L121, I would expect so but in cljs I can't seem to get it working 🤔
With sci/binding
Or in cljs maybe just use sci/alter-var-root
Since when using async those bindings go out of scope which sucks
I think parse-next + eval-form is what I'm looking for 👌
If you want sync eval, then use parse-next + eval-form. We could introduce a sci.core/eval-string+ as well
That would be nice, but I'm also cool with the more manual way
Everything is working perfectly!!! Thanks for the help ❤️
Cool! What are you doing, portal?
Yeah, working on exposing sci in portal via nrepl / socket repl
ah nice! you can check out nbb for nrepl / socket repl examples as well
also scittle (in browser nREPL)
So I'm adding middleware to an existing nrepl server, how does scittle do it?
scittle implements an nrepl server from scratch, so does nbb
but I'm curious to learn what you are doing, it sounds like it's something I haven't explored
Wait, how do clients connect to the browser?
Is there a proxy involved?
yes, there is a tiny proxy which is running in a bb process
Interesting 🤔 I went the piggieback/shadow-cljs route and implemented nrepl middleware that intercepts evals 😆
I hadn't even considered that. I'm sure there are interesting trade-offs
Yeah, I'm not a big fan of middleware but I did get something working. Might try https://github.com/babashka/sci.nrepl instead.
Yes but with eval-string ns is reset to the original binding, similar to load-string in Clojure
The sci.async ns has an eval-string+ function which returns the last ns binding as well. Sci/parse-next + eval-form allows you to save the last ns binding in case you are at the end of the stream
Eval-form doesn't reset the ns binding and requires you to bind ns yourself
Ohh, that makes sense. Thanks for the help! 🙏
How would I setup *1, *2, *3 and *e with eval-string+?