Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: add let-optionals* #77

Open
svenha opened this issue May 12, 2022 · 0 comments
Open

Feature request: add let-optionals* #77

svenha opened this issue May 12, 2022 · 0 comments

Comments

@svenha
Copy link
Contributor

svenha commented May 12, 2022

let-optionals* is a convenient way to handle optional arguments, see https://practical-scheme.net/wiliki/schemexref.cgi?let-optionals%2A

I have been using it in bigloo for many years and in hundreds of functions:

(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 ...))))

How about adding it to the core of bigloo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant