SRFI-177 vs. chibi's let-keywords
Amirouche Boubekki 25 Oct 2019 11:53 UTC
What is the advantage of SRFI-177 compared to chibi's let-keywords.
Here is the documentation that I found in the code:
;;> \macro{(let-keywords ls ((var [keyword] default) ... [rest]) body ...)}
;;>
;;> Analogous to \scheme{let-optionals}, except instead of binding the
;;> \var{var}s by position they are bound by name, by searching in
;;> \var{ls} with \scheme{keyword-ref*}. If an optional \var{keyword}
;;> argument is provided it must be an identifier to use as the name,
;;> otherwise \var{var} is used, appending a ":" (colon). If the name
;;> is not found, \var{var} is bound to \var{default}, even if unused
;;> names remain in \var{ls}.
;;>
;;> If an optional trailing identifier \var{rest} is provided, it is
;;> bound to the list of unused arguments not bound to any \var{var}.
;;>
;;> Note R7RS does not have a disjoint keyword type or auto-quoting
;;> syntax for keywords - they are simply identifiers. Thus when
;;> passing keyword arguments they must be quoted (or otherwise
;;> dynamically evaluated).
;;>
;;> \emph{Example:}
;;> \example{
;;> (define (make-person . o)
;;> (let-keywords o ((name "John Doe")
;;> (age 0)
;;> (occupation job: 'unemployed))
;;> (vector name age occupation)))
;;>
;;> (list (make-person)
;;> (make-person 'name: "Methuselah" 'age: 969)
;;> (make-person 'name: "Dr. Who" 'job: 'time-lord 'age: 1500))
;;> }
;;>
;;> \emph{Example:}
;;> \example{
;;> (let-keywords '(b: 2 a: 1 other: 9)
;;> ((a 0) (b 0) (c 0) rest)
;;> (list a b c rest))
;;> }
Thanks!
ref: https://github.com/ashinn/chibi-scheme/blob/master/lib/chibi/optional.scm