(use & args)
Like 'require, but also refers to each lib's namespace using clojure.core/refer. Use :use in the ns macro in preference to calling this directly. 'use accepts additional options in libspecs: :exclude, :only, :rename. The arguments and semantics for :exclude, :only, and :rename are the same as those documented for clojure.core/refer.
;; Use the namespace clojure.java.io:
user=> (use '(clojure.java io))
;; Imports only the split function from clojure.string.
user=> (use '[clojure.string :only (split)])
nil
;; split is now available without a namespace qualification.
user=> (split "hello world" #" ")
["hello" "world"]
;; You can also add the :as keyword to import the rest of clojure.string
;; with a namespace qualification.
user=> (use '[clojure.string :as s :only (split)])
nil
;; Now we can access any function in clojure.string using s.
user=> (s/replace "foobar" "foo" "squirrel")
"squirrelbar"
;; And we can still call split with or without the s qualification.
user=> (split "hello world" #" ")
["hello" "world"]
user=> (s/split "hello world" #" ")
["hello" "world"]
(ns some.namespace
(:require [clojure.contrib.json :as json])
(:use [clojure.string :only [trim lower-case split]]
[clojure.contrib.shell-out]
[clojure.pprint]
[clojure.test]))
;; use accepts other keywords from require that aren't listed in the docstring.
;; If you try to load a namespace, and it fails to load due to an error in
;; the source code, when you load it again after fixing the problem, you
;; can get a "namespace not found" exception. Use :reload to avoid this:
(use '[my.namespace] :reload)
;; However, if the error was in source for a namespace required or used
;; from my.namespace, you'll get the "namespace not found" exception
;; after fixing the problem, even using :reload. Use :reload-all to avoid this:
(use '[my.namespace] :reload-all)
;; You can also use :verbose, which does what you would think it would do:
(use '[my.namespace] :verbose)