Merge pull request #713 from mnieper/and-let

Fix and-let* so that it allows bodies according to SRFI 2.
This commit is contained in:
Alex Shinn 2020-11-25 14:40:16 +09:00 committed by GitHub
commit f9c00e0c21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -5,8 +5,10 @@
(begin (begin
(define-syntax and-let* (define-syntax and-let*
(syntax-rules () (syntax-rules ()
((and-let* ())
#t)
((and-let* () . body) ((and-let* () . body)
(begin #t . body)) (let () . body))
((and-let* ((var expr))) ((and-let* ((var expr)))
expr) expr)
((and-let* ((expr))) ((and-let* ((expr)))

View file

@ -42,4 +42,6 @@
(let ((x #f)) (and-let* (x (y (- x 1)) ((positive? y))) (/ x y)))) (let ((x #f)) (and-let* (x (y (- x 1)) ((positive? y))) (/ x y))))
(test 3/2 (test 3/2
(let ((x 3)) (and-let* (x (y (- x 1)) ((positive? y))) (/ x y)))) (let ((x 3)) (and-let* (x (y (- x 1)) ((positive? y))) (/ x y))))
(test 5 (and-let* () (define x 5) x))
(test 6 (and-let* ((x 6)) (define y x) y))
(test-end)))) (test-end))))