I have a function which loads expressions from another file, but I don’t know what the filename is, it is stored in a variable:
(defn run-migration [filename]
(load filename)
(run))
I know that all of these files have a common method called “run”. So I try to call it after loading in that function, but I get the “Unable to resolve symbol: run” error when I try to require this file in the repl, before the file is even loaded. Apparently clojure is trying to compile the file and “run” is not bound at that time because the load happens inside a function?
Possibly I am going about this the wrong way. Any guidance on a good (idiomatic) way to have a set of files that get loaded and run at runtime?
you can tell the compiler that the function
runwill defined later:that will get your file loaded into the repl. Perhaps you may want to set the namespace you load the file into by binding ns though this may not be necessarily.