Welcome! Please see the About page for a little more info on how this works.

0 votes
in REPL by

Question came up in #nrepl about how to see all of the things that load-file evaluates. My thinking was crank up a subrepl with a custom eval, load-file there, and then return. I was surprised that load-file doesn't use the repl's eval, but i'm not sure if that's an expectation i should have.

(clojure.main/repl
 :eval (fn [form]
         (prn "i could do something to: " form)
         (eval form))
 :read server/repl-read)

(load-file "stuff.clj")
"i could do something to: " (load-file "stuff.clj") ;; sees the load-file form
#'stuff/foo       ;; but not any of the forms in stuff.clj

I was naively expecting to get all of the forms from the file i was loading but that doesn't seem to be the case. Should load-file use the eval function of the current repl?

1 Answer

+2 votes
by
selected by
 
Best answer

The eval function of the current repl is for eval'ing things read by the repl, not all things eval'ed in the runtime. So, no this is not an expectation you should have.

...