store/[org.clojure/clojure "1.8.0"] clj::clojure.core/def

Official Documentation

Add notes

Docstring
==================================================
  Creates and interns a global var with the name
  of symbol in the current namespace (*ns*) or locates such a var if
  it already exists.  If init is supplied, it is evaluated, and the
  root binding of the var is set to the resulting value.  If init is
  not supplied, the root binding of the var is unaffected.

Example 1

Edit
;; give function another name
(def sys-map map)
;; => #'user/sys-map

;; give macro another name
(def #^{:macro true} sys-loop #'loop)
;; => #'user/sys-loop

;; Note that if the ^{:macro true} metadata were not preserved, sys-loop would
;; not be treated as a macro.

Example 2

Edit
;; This is an example of setting a docstring during a def.
;; (Note that the clojure.repl namespace which contains the
;;  doc function is not loaded by default in Emacs' SLIME mode.)

(def ted-nugent "the nuge rocks" 123)
;; => #'user/ted-nugent
(doc ted-nugent)
;; > -------------------------
;; > user/ted-nugent
;; > The nuge rocks
;; => nil
ted-nugent
;; => 123

Example 3

Edit
(def my-function (fn [x] (* x x x)))
;; => #'user/my-function

(my-function 4)
;; => 64

Example 4

Edit
(def my-val 5)
;; => #'user/my-val

my-val
;; => 5

Uses on crossclj