home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
s
/
s48.zip
/
MISC
/
VALUES.SCM
< prev
next >
Wrap
Text File
|
1992-07-06
|
697b
|
26 lines
; Copyright (c) 1992 by Richard Kelsey and Jonathan Rees. See file COPYING.
; Multiple return values (will be in Revised^5 Report)
(define multiple-value-token (vector 'multiple-value-token))
(define (values . things)
(if (and (pair? things)
(null? (cdr things)))
(car things)
(cons multiple-value-token things)))
(define (call-with-values producer consumer)
(let ((things (producer)))
(if (and (pair? things)
(eq? (car things) multiple-value-token))
(apply consumer (cdr things))
(consumer things))))
(define-syntax receive
(syntax-rules ()
((receive vars producer . body)
(call-with-values (lambda () producer)
(lambda vars . body)))))