Can any one give me a good example answer to differentiate between Use, Require and Import.
I hope someone can help me.
Can any one give me a good example answer to differentiate between Use, Require and Import.
I hope someone can help me.
require
ensures that a Clojure namespace has been compiled and instantiated.
:reload
key:as
key is provided.:refer
key is provided. The mapping is only visible from inside the requiring namespace, and is not transitive to other namespaces requiring it.use
is identical to require in action, except that the default is to modify the current namespace via the refer
function to include all the target namespace's vars as if :refer :all
had been provided. It accepts the :exclude
, :only
, and :rename
keys to guide the modification of the current namespace.
import
is for adding mappings of Class names to the current namespace, so that the package qualifiers will not need to be used.
In short, use require
You'll almost never want to mix-up symbols from different namespaces in the same namespace the way use
does, except during casual REPL work.
require
loads and compiles Clojure namespaces. import
allows you to avoid
using fully-qualified Java class names (the same as import
in Java).