let introduces lexical bindings. It is similar to Scheme’s letrec.
Syntax
(let (⟨binding⟩...)
⟨body⟩...)
;; ⟨binding⟩ := ⟨declare-form⟩
;; | (⟨var⟩ ⟨expr⟩)
;; | ((values ⟨var⟩...) ⟨expr⟩)
Semantics
letbinds recursively and in parallel.- It can introduce local helper functions as well as simple values.
- If you need top-to-bottom binding order, use
let*. - Bound variables may be declared with
declare. - Multiple values may be destructured with
values. ⟨body⟩forms an implicitprogn.
Example
(let ((declare x Integer)
(x (+ y 1))
(y 2))
(+ x y))