Skip to content

Instantly share code, notes, and snippets.

@nathanmarz
Created July 31, 2019 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanmarz/6c3461fd9f45e28248ace85eaee5a4f5 to your computer and use it in GitHub Desktop.
Save nathanmarz/6c3461fd9f45e28248ace85eaee5a4f5 to your computer and use it in GitHub Desktop.
Multiple namespace loading behavior
user=> (require 'test-ns)
Loading...
nil
user=> (require 'test-ns)
nil
user=> (require 'test_ns)
"Loading...
nil
user=> (require 'test_ns)
nil
(ns test-ns)
(println "Loading...)
@jafingerhut
Copy link

jafingerhut commented Jul 31, 2019

Weird. Note that doing the require of test-ns first causes only test-ns to be added to the clojure.core/*loaded-libs* set, whereas doing require of test_ns first causes both test-ns and test_ns to be added to clojure.core/*loaded-libs*.

@jafingerhut
Copy link

Addendum: There is additional error checking in require that checks whether the namespace with the require'd name was created when require is nearly done, but it is only enabled if you use the :as clause. Example given the contents of test_ns.clj above:

user=> (require '[test_ns :as myalias])
Loading...
Syntax error compiling at (REPL:1:1).
namespace 'test_ns' not found after loading '/test_ns'

That additional error checking is also enabled by doing (use 'test_ns)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment