Ref Type: Var
is a reference type which is isolated, synchronous, and autonomous:
- isolated - each thread has access to its own item
- synchronous - requested changes occur immediately
- autonomous - changes are made to a single item
Example: Add 1 to this thread's version of
, right now.
Vars provide a way to refer to a mutable storage location
that can be dynamically rebound on a per-thread basis.
for a more efficient alternative.
"CC" links to the official Clojure documentation; "CD" links to ClojureDocs.
- binding (CC, CD) - creates bindings for existing Vars
- defn (CC, CD) - defines a public function as a Var
- defn- (CC, CD) - defines a private function as a Var
- set! (CC, CD) - sets a thread-local-bound Var
- var (CC, CD) - creates and returns a Var
- var-get (CC, CD) - gets the value in the Var object
- var-set (CC, CD) - sets the value in the Var object
- with-redefs (CC, CD) - temporarily redefines Vars for a body
- with-redefs-fn (CC, CD) - temporarily redefines Vars for a function
To be continued...
This wiki page is maintained by Rich Morin
an independent consultant specializing in software design, development, and documentation.
Please feel free to email
comments, inquiries, suggestions, etc!