Next: , Previous: , Up: baselib expressions   [Index]


4.4.4 Assignments

Syntax: set! ?variable ?expression

?expression is evaluated, and the resulting value is stored in the location to which ?variable is bound. ?variable must be bound either in some region expression or at the top level. A syntax use of set! returns zero values.

(let ((x 2))
  (+ x 1)
  (set! x 4)
  (+ x 1)) ⇒ 5

It is a syntax violation if ?variable refers to an immutable binding.

NOTE The identifier set! is exported with level 1 as well.