Fork me on GitHub
#protorepl
<
2018-02-14
>
justinlee17:02:27

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)

justinlee17:02:01

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

seancorfield17:02:12

@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.

seancorfield17:02:38

(well, it will switch to the namespace of the form first, then evaluate it)

justinlee17:02:15

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?

justinlee17:02:28

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

justinlee17:02:29

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)

justinlee17:02:55

i’ve just been typing all of these magical incantations without comprehension

fellshard18:02:53

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.

fellshard18:02:46

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."

fellshard18:02:25

One changes the environment the REPL is sitting in, the other works with the REPL itself.

fellshard18:02:54

(I may be off point on some of this, correct me if I'm mistaken on the mechanics)

justinlee18:02:24

partial-answer: yes it looks for a top-level form beginning with /^\(ns / and parses that form

fellshard18:02:16

(Oh, I was answering the wrong question. : )

fellshard18:02:38

Does it work with other namespacing forms?

justinlee18:02:39

oh sorry @fellshard your answer was almost the exact same shape and size as mine i my mind skipped it 🙂

fellshard18:02:24

Naw, you're asking / answering a more specific question about how it determines which ns an executed form is in

justinlee18:02:56

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

justinlee18:02:24

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.

seancorfield18:02:23

@jasongilman is not around right now but he'd be the one to ask...

opsb18:02:52

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~?

seancorfield20:02:02

@oliver089 Does the REPL seem to start OK? You get the error just when you type code in?

opsb20:02:27

@seancorfield yes, it was in fact working when I first installed it, but when I reopened atom I hit that problem

seancorfield20:02:14

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...

seancorfield20:02:54

I always use a Clojure REPL instead.

seancorfield20:02:18

@oliver089 The self-hosted REPL doesn't care about Leiningen / Boot, since it just runs inside the IDE itself (as far as I know).

justinlee20:02:49

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

seancorfield20:02:04

@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.