(let bindings & body)
Binds expressions to symbols and makes those symbols available only within
bindings should be a vector with an even number of forms, ie:
[a1 b1, a2 b2, a3 b3]. The first item in a pair (the
as) should be a symbol that is assigned
the evaluation of the second item (the
bs). These symbols (the
as) are then
body (and not outside of
Another way to think about this is that the binding symbols in
let are like
defs that are only available within
In addition to direct symbol binding,
let supports a destructuring syntax to
"break apart" collections into multiple symbols. This destructuring syntax is
like it's own mini-language and allows for succinct code.
let is a wrapper over one of ClojureScript's special forms and is a
fundamental building block of the language. Many macros rely on
syntax and scope rules.
binding => binding-form init-expr binding-form => name, or destructuring-form destructuring-form => map-destructure-form, or seq-destructure-form Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein. See https://clojure.org/reference/special_forms#binding-forms for more information about destructuring.
(core/defmacro let [bindings & body] (assert-args let (vector? bindings) "a vector for its binding" (even? (count bindings)) "an even number of forms in binding vector") `(let* ~(destructure bindings) ~@body))