enforce order of let-optionals* val/rest binding in non-chibi impl (issue 778)

This commit is contained in:
Alex Shinn 2021-09-02 12:58:41 +09:00
parent 6be3784db0
commit 1881116804
3 changed files with 7 additions and 3 deletions

View file

@ -63,6 +63,10 @@
(test '(0 1 (2 3 4)) (test '(0 1 (2 3 4))
(let-optionals '(0 1 2 3 4) ((a 10) (b 11) . c) (let-optionals '(0 1 2 3 4) ((a 10) (b 11) . c)
(list a b c))) (list a b c)))
(let ((ls '()))
(let-optionals* ls ((a (begin (set! ls '(a b)) 'default-a))
(b 'default-b))
(test '(default-a default-b) (list a b))))
(test 5 (keyword-ref '(a: b: b: 5) 'b: #f)) (test 5 (keyword-ref '(a: b: b: 5) 'b: #f))
(test 5 (keyword-ref* '(a: b: b: 5) 'b: #f)) (test 5 (keyword-ref* '(a: b: b: 5) 'b: #f))
(cond-expand (cond-expand

View file

@ -29,7 +29,7 @@
;;> extra values are unused. ;;> extra values are unused.
;;> ;;>
;;> \var{ls} is evaluated only once. It is an error if any ;;> \var{ls} is evaluated only once. It is an error if any
;;> \var{default} mutates or set!s \var{ls}. ;;> \var{default} mutates \var{ls}.
;;> ;;>
;;> Typically used on the dotted rest list at the start of a lambda, ;;> Typically used on the dotted rest list at the start of a lambda,
;;> \scheme{let-optionals} is more concise and more efficient than ;;> \scheme{let-optionals} is more concise and more efficient than

View file

@ -32,8 +32,8 @@
(let ((tmp (op . args))) (let ((tmp (op . args)))
(let-optionals* tmp vars . body))) (let-optionals* tmp vars . body)))
((let-optionals* tmp ((var default) . rest) . body) ((let-optionals* tmp ((var default) . rest) . body)
(let ((var (if (pair? tmp) (car tmp) default)) (let* ((tmp2 (if (pair? tmp) (cdr tmp) '()))
(tmp2 (if (pair? tmp) (cdr tmp) '()))) (var (if (pair? tmp) (car tmp) default)))
(let-optionals* tmp2 rest . body))) (let-optionals* tmp2 rest . body)))
((let-optionals* tmp tail . body) ((let-optionals* tmp tail . body)
(let ((tail tmp)) . body)))) (let ((tail tmp)) . body))))