Skip to content

Feature request: add let-optionals* #77

@svenha

Description

@svenha

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions