mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 13:49:17 +02:00
This is much faster (in chibi) and more concise than case-lambda. Also adding (chibi optional) for the let-optionals and opt-lambda variants. Still need to add let-keywords*.
15 lines
558 B
Scheme
15 lines
558 B
Scheme
|
|
(define-syntax let-optionals
|
|
(syntax-rules ()
|
|
((let-optionals ("step") ls (vars ...) ((v d) . rest) . body)
|
|
(let-optionals ("step") ls (vars ... (v tmp d)) rest . body))
|
|
((let-optionals ("step") ls ((var tmp default) ...) rest . body)
|
|
(let-optionals* ls ((tmp default) ... . rest)
|
|
(let ((var tmp) ...) . body)))
|
|
((let-optionals ls vars . body)
|
|
(let-optionals ("step") ls () vars . body))))
|
|
|
|
(define-syntax opt-lambda
|
|
(syntax-rules ()
|
|
((opt-lambda vars . body)
|
|
(lambda args (let-optionals args vars . body)))))
|