Fix and-let* so that it allows bodies according to SRFI 2.

This commit is contained in:
Marc Nieper-Wißkirchen 2020-10-22 15:13:04 +02:00
parent 12636f4b19
commit 306dbd470a
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))))