Previous: Internal definitions, Up: Variable definitions [Index]
Another kind of definition is provided by define-values
, which
creates multiple definitions from a single expression returning multiple
values. It is allowed wherever define is allowed.
It is an error if a variable appears more than once in the set of ⟨formals⟩.
Semantics: ⟨Expression⟩ is evaluated, and the ⟨formals⟩ are
bound to the return values in the same way that the ⟨formals⟩ in a
lambda
expression are matched to the arguments in a procedure call.
(define-values (x y) (exact-integer-sqrt 17)) (list x y) ⇒ (4 1) (let () (define-values (x y) (values 1 2)) (+ x y)) ⇒ 3