Fork me on GitHub
#cursive
<
2023-12-20
>
Rachel Westmacott18:12:16

Has anyone got any experience of using https://github.com/vlaaad/remote-repl with Cursive?

Rachel Westmacott18:12:38

When I've tried to use it it appears to connect (I get a user=> printed) but any input I give it doesn't seem to go anywhere.

cfleming21:12:27

@U47G49KHQ uses Cursive (or used to, at least), so might know…

vlaaad21:12:18

Used to, still am 🙂

❤️ 2
vlaaad21:12:51

Please share the run configuration

Rachel Westmacott09:12:52

It is fairly vanilla.

vlaaad09:12:41

You need to use clojure.main REPL type instead of nREPL

👍 1
Rachel Westmacott09:12:19

ah, yes, that seems to work much better, thank you gratitude

Rachel Westmacott09:12:02

it does come with a Cursive warning about being less good, but I expect/hope it will be good enough

Rachel Westmacott09:12:38

"This option provides a more limited REPL.[...]" etc.

vlaaad09:12:34

if you want an explanation for that, here it is: nREPL is like a non-blocking web server: IDE sends non-blocking requests, then it receives the results asynchronously. It has some niceties to it, e.g. IDE can send some special messages from time to time, and they won’t interrupt your code evaluations. An example of such message is changing the current namespace to the namespace of the file you currently have open in the IDE. Socket REPLs are synchronous and blocking: If you send a form, and evaluation of this form blocks the REPL thread, no further forms are processed until this one ends. Also, the form you submitted to a socket REPL might read from the process standard input, making it behave differently, so IDE can’t really send any commands safely, because how the form is interpreted might change. Because of that, the IDE can’t change the current namespace for you. On the other hand, this approach enables some interesting interactions that are not possible with the nREPL, e.g. the remote-repl library — it blocks the current thread and reads from stdin, which “upgrades” the socket REPL so it pipes the data it receives to another remote socket REPL.

thanks3 2
Rachel Westmacott09:12:14

That's... a very helpful explanation, thank you.

vlaaad09:12:00

It’s possible to go absolutely wild with upgrading socket REPLs, e.g. you can make a REPL that responds to plain-text messages, uses LLM to convert plain text message to Clojure code and evaluates that: https://gist.github.com/vlaaad/f1f44c0f1404ee54710a4a225cf7ba62

👀 1
😮 1
🎉 1
vlaaad09:12:31

I experimented with using ChatGPT to handle plain text queries and errors and produce code that I can then choose to evaluate

vlaaad09:12:11

very fun, but yeah, somewhat limits what the IDE can do

kennytilton19:12:12

Note for when CLJD comes on line: CLJD supports keyword parameters. eg:

(defn counter-home-page [.title "Untitled"]
  ...)
So the arity of this is one, not two:
(counter-home-page .title "Flutter/MX Counter Demo")
Come to think of it, supporting keywords is more than an arity issue! Anyway, hth.