nrepl

https://github.com/nrepl/nrepl || https://nrepl.org
kwrooijen 2020-03-31T14:04:45.005500Z

Hi! I want to create a UI that modifies Clojure functions. Basically in the UI there should be a text editor containing a specific function's (or defmethod) body. On save that function body should change in the selected project. Is NREPL the correct tool for this? I was thinking of having an NREPL start in the Clojure application, and the UI would communicate through that. Is that a viable option or would I have to use a different method?

kwrooijen 2020-03-31T14:05:54.006500Z

I don't think NREPL can actually change the code in the file. But maybe it can help with finding function locations and such?

kwrooijen 2020-03-31T14:06:53.006800Z

Any advice would be appreciated :simple_smile:

bozhidar 2020-04-01T08:14:54.014100Z

Well, you can do pretty much everything with a REPL, so while it’s main purpose is to eval code, there’s no limit to what that code can do. It’d be pretty easy to figure out where something is defined simply by checking it’s metadata.

kwrooijen 2020-04-01T08:19:46.014300Z

Oh wow. I didn't even know function definitions have meta data. (well I should've, since I do use ^:private quite a bit)

kwrooijen 2020-04-01T08:21:21.014500Z

So if I were to attach to an NREPL in a specific project, I could check the metadata like you said

kwrooijen 2020-04-01T08:21:45.014700Z

Thank you, Clojure is full of surprises for me 🙂

kwrooijen 2020-03-31T14:11:34.007100Z

Well, this might answer my question on defmethods at least: https://stackoverflow.com/questions/52861401/dynamically-get-the-source-strings-of-clojure-multimethod-implementation