Fork me on GitHub
#chlorine
<
2020-08-24
>
seancorfield04:08:17

I realized tonight that it would be really easy to create a Socket REPL adapter that automatically submits forms/values to Cognitect's REBL, without needing the customization I've previously been adding to Chlorine: https://github.com/seancorfield/socket-rebl -- this would also be usable by Clover to integrate with REBL, without needing custom code.

seancorfield05:08:07

Ah, I've just realized why this won't actually work! Chlorine starts up a separate Socket REPL over which it sends the actual evaluations 😞

seancorfield05:08:29

I suspect Clover does the same? Oh well, it's still a nice, useful utility for folks who want to telnet into a REBL instance with a Socket REPL I suppose 😞

mauricio.szabo12:08:23

Almost - Chlorine sends a piece of code that will make the REPL more programmable. Without it, it would be really difficult to add tooling over the REPL.

mauricio.szabo12:08:06

But... maybe we can somehow work on this direction? Maybe make this "socket REBL" return the form that Chlorine expects? I'll investigate alternatives 😄

mauricio.szabo12:08:57

(after all, there's currently support for at least 4 different REPLS: the "regular socket REPL", "Clojure with UNREPL", "nREPL", and "Shadow-CLJS Relay REPL")

seancorfield17:08:36

@mauricio.szabo The only difference between the bare bones Socket REPL and my library above, is the :eval function is wrapped to call cognitect.rebl/submit on the form and value: https://github.com/seancorfield/socket-rebl/blob/master/src/socket/rebl.clj#L13-L21

seancorfield17:08:25

What's interesting is that this causes REBL to show the negotiation that Chlorine does, since it adds all those initial forms to REBL as they are evaluated. But once Chlorine has negotiated that this is a regular Socket REPL on the JVM, I gather that starts a second socket REPL for the unrepl stuff to communicate over?

seancorfield17:08:06

Here's what I see in REBL, sent by Chlorine, before it switches over to a separate socket REPL:

seancorfield17:08:42

(it's in reverse time order: most recent command at the top)

mauricio.szabo18:08:44

Yes, there are two REPLs connected: one for autocomplete, load-file, goto-var-definition, etc, and another for evaluations so using one doesn't interfere on other 🙂

seancorfield18:08:34

It sure would be nice if they were swapped around so evaluations happened on the primary REPL and all the other stuff happened on the secondary.

seancorfield18:08:49

(since the primary REPL is the one users have control over)

seancorfield18:08:43

I didn't dig too deep into non-eval ops to see if anything else uses the primary REPL. Will do that when I get off my daily standup.

mauricio.szabo18:08:51

(I believe that's the way it is - the first REPL to be connected is the "primary" 😄)

seancorfield18:08:56

OK, I tested, and it doesn't look like anything goes over the primary socket REPL after the negotiation code.

seancorfield18:08:12

I verified that connecting to that Socket REPL from other sources (e.g., telnet) does indeed go through that submit-eval above, so socket.rebl/repl is used as the :accept for new connections, but none of Chlorine's built-in operations go through it, so all of the operations must be happening on secondary socket REPLs that are opened after negotiation @mauricio.szabo FYI

mauricio.szabo18:08:13

No, I believe I know what happens... As Chlorine is using UNREPL, it is probably starting a new REPL inside the Socket REPL - by running clojure.main/repl or something, so when it issues this command, it never returns then newer commands never go through...

seancorfield18:08:58

Ah, yes, that would do it too 🙂

seancorfield18:08:37

So unrepl would essentially need an :eval middleware wrapper in order to make my socket.rebl stuff work. Oh well...

mauricio.szabo23:08:18

Some experiments: by using some new features of interactive-renderer, I'm trying to change the way test errors are being rendered on the editor: