Portable let-optionals* pasted by sjamaan on Thu Oct 3 09:22:33 2019
(define-syntax let-optionals*
(syntax-rules ()
((_ ?args ((?var0 ?default0) ?more-bindings ...) ?body ...)
(let ((tmp ?args))
(let ((?var0 (if (null? tmp) ?default0 (car tmp))))
(let-optionals* (if (null? tmp) '() (cdr tmp)) (?more-bindings ...)
?body ...))))
((_ ?args (?rest) ?body ...)
(let ((?rest ?args))
?body ...))))
Fixed version when no remaining rest args are collected added by sjamaan on Thu Oct 3 21:36:11 2019
(define-syntax let-optionals*
(syntax-rules ()
((_ ?args ((?var0 ?default0) ?more-bindings ...) ?body ...)
(let ((tmp ?args))
(let ((?var0 (if (null? tmp) ?default0 (car tmp))))
(let-optionals* (if (null? tmp) '() (cdr tmp)) (?more-bindings ...)
?body ...))))
((_ ?args () ?body ...)
(begin ?body ...))
((_ ?args (?rest) ?body ...)
(let ((?rest ?args))
?body ...))))