Implement let-values

TODO: Support more than one set of bindings
This commit is contained in:
Lassi Kortela 2019-09-03 10:02:05 +03:00
parent 573d02ac64
commit 738f8bec62
2 changed files with 3039 additions and 3012 deletions

File diff suppressed because it is too large Load Diff

View File

@ -515,6 +515,15 @@
`(call-with-values (lambda () ,expr) `(call-with-values (lambda () ,expr)
(lambda ,formals ,@body))) (lambda ,formals ,@body)))
(define-macro (let-values bindings . body)
(unless (pair? bindings) (error "let-values: syntax error"))
(let* ((binding (car bindings))
(names (car binding))
(form (cadr binding)))
(unless (null? (cddr binding)) (error "let-values: syntax error"))
(unless (null? (cdr bindings)) (error "let-values: syntax error"))
`(receive ,names ,form ,@body)))
(define-macro (dotimes var . body) (define-macro (dotimes var . body)
(let ((v (car var)) (let ((v (car var))
(cnt (cadr var))) (cnt (cadr var)))