Ideas about how to handle Socket REPL in the future #241
mauricioszabo
started this conversation in
General
Replies: 1 comment 1 reply
-
Thank you for this write-up! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Right now, Chlorine adds a blob of Clojure code to Socket REPL and then "transforms it" into a programmable REPL. It uses UNREPL. This gives us good support for tooling, but there are some inputs that can break the whole REPL (notably, Datahike library) and also it's quite a pain to support the more advanced features that I want to add like interactive renders, etc.
So, I'm thinking on some alternatives for newer versions. I'm thinking about adding two new configs: one for REPL Mode and one from Printer Mode (I need to rethink these names to be more self-explanatory), but the idea is that REPL Mode is how the REPL behave, and Printer Mode is how the results will be wrapped/rendered on Chlorine.
So, for available REPL Modes, I'm thinking on (ordered for the "simpler one" to "more advanced"):
Fully unstructured REPL ("Inferior REPL mode")
This would just evaluate forms, and the very next code that returns will be understood as the output. So, if someone writes
(prn {:a 10 :b 20})
, Chlorine will think that the map is the "result" and thatnil
(the result ofprn
) is the "stdout". This is obviously very crude, but it can open the door for great things like connecting to more socket-repl-like elements that would capture the output (I believe Reveal have an option to work as a socket REPL too), or toolings like https://github.com/seancorfield/socket-reblRewrite code before sending to REPL ("Wrapped input mode")
This will wrap the code in something like
[tooling$repl-result <some-id> "string-with-the-result"]
and then try to use this EDN format to detect what is an output and what is not. This is already how things are done in environments like Clojerl, Joker, etc.Upgrade the REPL to be programmable ("Programmable REPL mode")
This will do exactly the same thing we're doing today with UNREPL, but with a simple alternative that maybe is more portable. This will be the only way to have "break evaluation" on some environments, and I'm thinking if it's possible to support Clojure, Clojure.CLR, and maybe Clojerl, Lumo, and Plank. Unfortunately, ClojureScript REPLs will never support break evaluation...
Specific REPL
This is not a different mode per se, but I'm thinking about adding full-class support for
prepl
(so maybe Figwheel REPL can be used) and Shadow remote API (for both Clojure and ClojureScript). I'm not yet sure about this later option, so maybe I'll add a specific config for Shadow (like "always use shadow-remote") because I believe there are people that may want to use a different "REPL Mode" for Clojure and ClojureScript.So, if someone says that he wants to use "Programmable REPL" and that option is not available on his REPL, he would fallback to the "Wrapped input" for example.
Beta Was this translation helpful? Give feedback.
All reactions