Reputation: 1266
In Common Lisp it's easy http://clhs.lisp.se/Body/v_ld_pns.htm because the special variable is being set at the load time.
However, I don't seem to be able to find how to do it in Clojure. Is there a way to find which file was passed to load-file?
Upvotes: 1
Views: 120
Reputation: 38799
The load-file
function eventually reaches Compiler.java#L7395, where it dynamically binds the source name (when it exists) to the variable designated by SOURCE
(see Compiler.java#L235), a.k.a. clojure.core/*source-path*
.
In /tmp/test.clj
:
(print clojure.core/*source-path*)
In the REPL:
user=> (load-file "/tmp/test.clj")
test.cljnil
Upvotes: 2