Simple version of call-with-values

This commit is contained in:
Justin Ethier 2016-01-27 22:32:31 -05:00
parent 163d399f07
commit 14f42a0b5a

View file

@ -322,16 +322,16 @@
(if (and (not (null? args)) (null? (cdr args)))
(car args)
(cons (cons 'multiple 'values) args))))
(define call-with-values
(lambda (producer consumer)
(let ((x (producer)))
(if ;(magic? x)
(and (pair? x) (equal? (car x) (cons 'multiple 'values)))
(apply consumer (cdr x))
(consumer x)))))
;; TODO: just need something good enough for bootstrapping (for now)
;; does not have to be perfect (this is not, does not handle call/cc or exceptions)
; (define call-with-values
; (lambda (producer consumer)
; (let ((x (producer)))
; (if ;(magic? x)
; (and (pair? x) (equal? (car x) (cons 'multiple 'values)))
; (apply consumer (cdr x))
; (consumer x)))))
(define (dynamic-wind before thunk after)
(before)
(let ((result (thunk)))