sci

djblue 2022-09-17T06:04:56.118429Z

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 🤔

borkdude 2022-09-17T07:01:51.727249Z

With sci/binding

borkdude 2022-09-17T07:02:45.545969Z

Or in cljs maybe just use sci/alter-var-root

borkdude 2022-09-17T07:03:02.779709Z

Since when using async those bindings go out of scope which sucks

☝️ 1
djblue 2022-09-17T07:03:40.394709Z

I think parse-next + eval-form is what I'm looking for 👌

borkdude 2022-09-17T07:04:13.099069Z

If you want sync eval, then use parse-next + eval-form. We could introduce a sci.core/eval-string+ as well

djblue 2022-09-17T07:08:06.582439Z

That would be nice, but I'm also cool with the more manual way

djblue 2022-09-17T07:21:15.970199Z

Everything is working perfectly!!! Thanks for the help ❤️

borkdude 2022-09-17T07:54:19.156539Z

Cool! What are you doing, portal?

djblue 2022-09-17T07:55:33.359099Z

Yeah, working on exposing sci in portal via nrepl / socket repl

borkdude 2022-09-17T07:56:02.849219Z

ah nice! you can check out nbb for nrepl / socket repl examples as well

👍 1
borkdude 2022-09-17T07:56:42.563629Z

also scittle (in browser nREPL)

djblue 2022-09-17T07:57:16.382849Z

So I'm adding middleware to an existing nrepl server, how does scittle do it?

borkdude 2022-09-17T07:57:36.852899Z

scittle implements an nrepl server from scratch, so does nbb

borkdude 2022-09-17T07:57:51.899429Z

but I'm curious to learn what you are doing, it sounds like it's something I haven't explored

djblue 2022-09-17T07:59:00.818209Z

Wait, how do clients connect to the browser?

djblue 2022-09-17T07:59:23.784499Z

Is there a proxy involved?

borkdude 2022-09-17T08:00:12.686769Z

yes, there is a tiny proxy which is running in a bb process

djblue 2022-09-17T08:02:07.632099Z

Interesting 🤔 I went the piggieback/shadow-cljs route and implemented nrepl middleware that intercepts evals 😆

borkdude 2022-09-17T08:04:03.813479Z

I hadn't even considered that. I'm sure there are interesting trade-offs

djblue 2022-09-17T08:10:36.816139Z

Yeah, I'm not a big fan of middleware but I did get something working. Might try https://github.com/babashka/sci.nrepl instead.

borkdude 2022-09-17T06:40:37.837029Z

Yes but with eval-string ns is reset to the original binding, similar to load-string in Clojure

borkdude 2022-09-17T06:42:49.546949Z

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

borkdude 2022-09-17T06:43:29.974619Z

Eval-form doesn't reset the ns binding and requires you to bind ns yourself

djblue 2022-09-17T06:58:04.183079Z

Ohh, that makes sense. Thanks for the help! 🙏

djblue 2022-09-17T06:59:48.287549Z

How would I setup *1, *2, *3 and *e with eval-string+?