mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 21:59:17 +02:00
enforce order of let-optionals* val/rest binding in non-chibi impl (issue 778)
This commit is contained in:
parent
6be3784db0
commit
1881116804
3 changed files with 7 additions and 3 deletions
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue