-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for pausing/resuming a CLJS REPL #73
Comments
Yeah, that'd be pretty cool! |
This seems pretty similar to @cgrand concept of |
@arichiardi modal repls were discussed months ago with @cursive-ide who thought they have poor usability. |
This idea is interesting, I have another idea in the pipeline, a This would give cljs tooling a very simple way of using the connection if needed and it would have all the information it needs available (including a way to easily eval in the js env client). |
Why not consider a special form/taglit (or abuse of conditional reader) to determine in which env should a piece of code be run? |
Abusing the conditional reader is a very interesting solution. |
In fact, we could set it up so that it's not really abuse, it's just that an implied conditional is set for code without conditionals. |
I was sure some cool idea would come out of this 😄 |
That sounds like an amazing idea! Would be game changing for a tool like CIDER. |
Practically speaking in the short term, this means top level reader conditionals of the form |
That's exactly what I meant by abuse: considering an implicit conditional when none. |
I already mentioned my reservations about this in the #cider slack but let me repeat it here so it doesn't get lost. The problem with In shadow-cljs these can all run in parallel and you can "select" which REPL to talk to at any time.
I suggested to use The broader problem however is that ClojureScript is not like Clojure and maybe we should re-think some assumptions about the REPL. One issue is that the Read runs in a different runtime than Eval/Print. For the Browser REPL it is very possible (and common) that the user reloads the Browser which means all state that might have been accumulated is lost. The compiler-env however is still around so the compiler thinks state exists when it doesn't.
You also can't Read inside Eval since JS doesn't have a blocking streaming stdin (or stdin at all in the case of the Browser). And since there are different runtimes for each build most of the tooling is in a weird situation. You might be editing There is also this weird and common issue that a REPL might actually have multiple runtimes connected. Say you have the This went way off-topic so I'll stop here. PS: I'm absolutely not a fan of abusing reader conditionals for this, that just seems like a hack gone too far. The client knows if it wants to eval CLJS or CLJ. It should tell this to the nrepl middleware via either different ops or extra attributes in the message. |
Re-reading this last post multiple times. It makes a lot of sense to me to try to come up with a cljs-specific nREPL mini-protocol. It could be handled by its own middleware for achieving isolation and could be initially behind feature flag so that we do not break the existing behavior. For me all the above makes sense as I have directly experienced all of the problems above (especially the namespace not compiled one!). I will see if I can come up with some simple stuff that brings together ideas spread in there issues. |
@arichiardi I'm not a believer in a mini protocol, it's coupled and specific and would require an every growing set of operations. Almost everything that needs to be done can be done with a clojure library with I do think suspend and resume are good ideas and contrary to the post above you can resume because you are keeping track of the session ids. |
(Originally proposed in #28, which couldn't be applied due to the 0.2.0 rewrite landing.)
Basic outline:
:cljs/pause
would be intercepted and shift the REPL environment over to a different dynamic var, thus restoring the nREPL session to Clojure "mode".:cljs/resume
would restore the REPL environment, putting the session back in ClojureScript "mode".Should be pretty easy, and make using piggieback a lot easier, i.e. make it less necessary to have two nREPL sessions going in a lot of cases (one Clojure, the other piggiebacked CLJS).
The text was updated successfully, but these errors were encountered: