what is protorepl actually doing when you start executing a form from a file? is it parsing your ns
declaration to figure out what your namespace aliases are? or does it communicate with the build process (or the lein server repl or whatever the right terminology is)
i’m asking because i am using shadow-cljs and now protorepl is dumping a bunch of errors and i don’t know how to diagnose because i don’t understand what it is doing
@lee.justin.m If you execute a whole file, it just tells the REPL to load
that file. If you execute a form, it literally just sends it to the REPL as-is to evaluate.
(well, it will switch to the namespace of the form first, then evaluate it)
how does it know to switch to the namespace of the form? is that something that the protorepl code does by parsing the ns
form?
once, when i had a functioning protorepl, i was just able to send a bunch of specter forms to the repl and everything worked. so i think it must have understood my imports because the forms were not fully qualified
the other related thing i don’t understand is that this was only possible (I think) when I started figwheel inside the repl and then executed (cljs-repl)
i’ve just been typing all of these magical incantations without comprehension
Note too that if you send a file, it sends the file on disk, not the file in your Atom buffer. Save before sending files and you'll get what you see.
Sending a file to the REPL doesn't change the REPL's namespace; it just loads the definitions in their namespace. If you send the ns
form directly, it's just as if you typed that into the REPL, and will change the namespace, expose any included definitions, etc.
You can think of sending a file as being declarative: "I want these definitions around." Sending a form is more declarative: "Execute this and tell me what the result is."
One changes the environment the REPL is sitting in, the other works with the REPL itself.
(I may be off point on some of this, correct me if I'm mistaken on the mechanics)
partial-answer: yes it looks for a top-level form beginning with /^\(ns /
and parses that form
(Oh, I was answering the wrong question. : )
Does it work with other namespacing forms?
oh sorry @fellshard your answer was almost the exact same shape and size as mine i my mind skipped it 🙂
Naw, you're asking / answering a more specific question about how it determines which ns an executed form is in
before i switched to shadow-cljs and broke everything, I thought that I was capable of starting figwheel in the repl and then executing forms from my source code, even when the forms did things like reference shortened ns aliases. maybe i imagined that
looking at the protorepl source code it doesn’t seem possible that that could work but again, i do not understand the complexities of clj vs. cljs repl and what it means to connect to an nrepl, etc.
@jasongilman is not around right now but he'd be the one to ask...
Hey, crossposting from #editors... (hadn't had a response today and it was suggested here might be a better place)
I've installed proto-repl for atom but whenever I try to run code in a self-hosted repl I get the error TypeError: Cannot set property 'user' of undefined
. I've set the path to the lein
binary, is there any other configuration that might need setting up or perhaps someone recognises this issue~?
@oliver089 Does the REPL seem to start OK? You get the error just when you type code in?
@seancorfield yes, it was in fact working when I first installed it, but when I reopened atom I hit that problem
I've never used the self-hosted REPL (since it's cljs) but I just went and tried it and I get the same error. So I guess the self-hosted REPL is just broken at the moment...
I always use a Clojure REPL instead.
@oliver089 The self-hosted REPL doesn't care about Leiningen / Boot, since it just runs inside the IDE itself (as far as I know).
so what do people who write cljs actually use? i guess they just do it via the terminal? i’ve had very little luck getting cljs editor integrations to work, including cider
@lee.justin.m No idea. We gave up on cljs years ago because the tooling was so flaky. I hear it's much-improved now but I still see a lot of people struggling with cljs REPL setup so I'm not much inclined to try again yet. Maybe one day.