Liking cljdoc? Tell your friends :D
Clojure only.

com.xadecimal.mutable-var


var-scopecljmacro

(var-scope & body)

Creates a block scope where you can declare mutable variables using (var <name> <value>) and mutate it using (set! <name> <new-value>).

Mutable variables follow these semantics:

  • variables are scoped to their block
  • variables are allowed to shadow each other
  • inner block scope can reuse the name of an outer block scope variable
  • you cannot refer to a variable declared later prior to it being declared
  • you cannot redefine the same variable (var i 0) (var i 1), you must instead assign a different value to existing defined variable: (set! i 1)
  • when var is primitive, you cannot change the inferred type through mutation, if defined as a long only long values can be set! to it
  • inner block scopes see all variables from outer blocks and can access and mutate them
Creates a block scope where you can declare mutable variables using
(var <name> <value>) and mutate it using (set! <name> <new-value>).

Mutable variables follow these semantics:
 - variables are scoped to their block
 - variables are allowed to shadow each other
 - inner block scope can reuse the name of an outer block scope variable
 - you cannot refer to a variable declared later prior to it being declared
 - you cannot redefine the same variable (var i 0) (var i 1), you must
   instead assign a different value to existing defined variable: (set! i 1)
 - when var is primitive, you cannot change the inferred type through
   mutation, if defined as a long only long values can be set! to it
 - inner block scopes see all variables from outer blocks and can access and
   mutate them
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close