ClojureDocs

Nav

Namespaces

*file*

clojure.core

Available since 1.0
    The path of the file being evaluated, as a String.
     When there is no file, e.g. in the REPL, the value is not defined.
    1 Example
    ;; Given a file named "example.clj" is available in the current folder
    ;; with content:
    
    (ns example)
    (when *compile-files* (println "Compiling:" *file*))
    
    ;; If we start a REPL adding "." as part of the classpath,
    ;; then we can see the following:
    
    (binding [*compile-path* "."]
      (compile 'example))
    ;; Compiling: example.clj
    ;; example
    
    See Also
    No see-alsos for clojure.core/*file*
    2 Notes
      By , created 13.3 years ago, updated 13.3 years ago

      Does this actually work? I couldn't get it to print anything but NO_SOURCE_PATH. (And no, this wasn't in the REPL.)

      By , created 12.6 years ago

      If you're having trouble getting this feature to work as advertised, check out this StackOverflow Question.