protorepl

justinlee 2018-02-14T17:20:27.000661Z

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)

justinlee 2018-02-14T17:21:01.000792Z

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

seancorfield 2018-02-14T17:46:12.000097Z

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

seancorfield 2018-02-14T17:46:38.000615Z

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

justinlee 2018-02-14T17:48:15.000645Z

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?

justinlee 2018-02-14T17:49:28.000338Z

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

justinlee 2018-02-14T17:50:29.000577Z

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)

justinlee 2018-02-14T17:50:55.000070Z

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

fellshard 2018-02-14T18:11:53.000019Z

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.

fellshard 2018-02-14T18:12:46.000481Z

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

fellshard 2018-02-14T18:13:25.000583Z

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

fellshard 2018-02-14T18:13:54.000673Z

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

justinlee 2018-02-14T18:15:24.000783Z

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

fellshard 2018-02-14T18:20:16.000421Z

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

fellshard 2018-02-14T18:21:38.000239Z

Does it work with other namespacing forms?

justinlee 2018-02-14T18:21:39.000803Z

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

fellshard 2018-02-14T18:22:24.000652Z

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

justinlee 2018-02-14T18:22:56.000451Z

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

justinlee 2018-02-14T18:24:24.000699Z

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.

seancorfield 2018-02-14T18:25:23.000506Z

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

opsb 2018-02-14T18:26:52.000110Z

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

seancorfield 2018-02-14T20:16:02.000627Z

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

opsb 2018-02-14T20:17:27.000078Z

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

seancorfield 2018-02-14T20:27:14.000680Z

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

seancorfield 2018-02-14T20:27:54.000146Z

I always use a Clojure REPL instead.

seancorfield 2018-02-14T20:29:18.000292Z

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

justinlee 2018-02-14T20:29:49.000034Z

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

seancorfield 2018-02-14T20:31:04.000180Z

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