by Marc Nieper-Wißkirchen
This SRFI is currently in final status. Here is an explanation of each status that a SRFI can hold. To provide input on this SRFI, please send email to
firstname.lastname@example.org. To subscribe to the list, follow these instructions. You can access previous messages via the mailing list archive.
define-values form is a definition that binds
multiple variables from a single expression returning multiple
This SRFI makes the
which was standardized in R7RS, available to
It is preferable for
define-values to be
implemented in the Scheme system's core so that modifications of
an algorithm like the one described
in Fixing Letrec
(reloaded) can be employed to
define-values definitions as effectively
as other internal variable definitions.
This specification describes the
(srfi :244 define-values) libraries.
define-values form described in this specification is
〈definition〉 and may appear anywhere
other definitions may appear.
(define-values 〈formals〉 〈expression〉)
Syntax: Any variable must not appear more than once in
the set of
Semantics: The variables occurring in
〈formals〉 are bound to fresh
locations containing the values returned by
〈formals〉 are matched to the return
values in the same way that the
lambda expression are matched to the arguments
in a procedure call. The effect of the
not matching is undefined.
The continuation of
not be invoked more than once.
(define-values (x y) (values 1 2)) (+ x y) ⟹ 3 (define-values (a . b) (values 1 2)) (cons a b) ⟹ (1 2)
Sample implementation as a portable R6RS library
The form described in this SRFI has been well-known for a long time.
I would like to thank Jim Rees for pointing out to me that the
original sample implementation violated the R6RS
requirement that it is a syntax violation to
set! with exported variables.
Abdulaziz Ghuloum and R. Kent Dybvig. Fixing letrec (reloaded). In Proceedings of the 2009 Workshop on Scheme and Functional Programming, 57–65, 2009.
© 2022 Marc Nieper-Wißkirchen.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.