store/[org.clojure/clojure "1.8.0"] clj::clojure.core/create-ns

Official Documentation

Add notes
Arities
==================================================
   [sym]

Docstring
==================================================
  Create a new namespace named by the symbol if one doesn't already
  exist, returns it or the already-existing namespace of the same
  name.

Source

(defn create-ns
  "Create a new namespace named by the symbol if one doesn't already
  exist, returns it or the already-existing namespace of the same
  name."
  {:added "1.0"
   :static true}
  [sym] (clojure.lang.Namespace/findOrCreate sym))

Example 1

Edit
;; If you try this, you're doing it wrong
(create-ns my-new-namespace)
;; => java.lang.Exception: Unable to resolve symbol: my-new-namespace in this context (NO_SOURCE_FILE:2)


;; Same deal, if you try this, you're doing it wrong
(create-ns "my-new-namespace")
;; => java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol (NO_SOURCE_FILE:0)


;; This is how you do it
(create-ns 'my-new-namespace)
;; => #<Namespace my-new-namespace>

Example 2

Edit
;; Let's create a namespace and check for our result
;; the new namespace will be "my-new-namespace"

;; obviously, it does not exist yet, so looking for it, finds nothing
(find-ns 'my-new-namespace) 
;; => nil

;; let's create it
(create-ns 'my-new-namespace)
;; => #<Namespace my-new-namespace>

;; now searching for it again will have a result
(find-ns 'my-new-namespace)
;; => #<Namespace my-new-namespace>

Example 3

Edit
;; You can create a namespace, not switch to it and still work in, by storing it

;; create the namespace
(def for-later-use (create-ns 'my-namespace))
;; => #'user/for-later-use

;; assign a value for a variable
(intern for-later-use 'my-var "some value")
;; => #'my-namespace/my-var

;; notice how the "for-later-use" symbol has been evaluated to the namespace it represents

;; check the new variable
my-namespace/my-var
;; => "some value"

;; you can also work on a namespace by using the its name
;; (but quoting it) instead of the return of "create-ns"
(intern 'my-namespace 'my-var "some other value")
;; => #'my-namespace/my-var

;; check the new assignment and see what's changed
my-namespace/my-var
;; => "some other value"

Uses on crossclj