3 keyword-case-lambda
(require keyword-lambda/keyword-case-lambda) | |
package: hash-lambda |
syntax
(keyword-case-lambda clause ...)
clause = [kw-formals maybe-when body-expr ...+] | [#:args-hash match-pattern maybe-when body-expr ...+] | [#:rest match-pattern maybe-when body-expr ...+] |
[#:kws match-pattern #:kw-args match-pattern #:rest match-pattern maybe-when body-expr ...+] | [_ maybe-when body-expr ...+] | [else maybe-when body-expr ...+] | [#:when condition-expr body-expr ...+] | [#:unless condition-expr body-expr ...+] maybe-when =
| #:when condition-expr | #:unless condition-expr kw-formals = (arg ...) | (arg ... . rest-id) | rest-id arg = id | [id default-expr] | keyword id | keyword [id default-expr]
The kw-formals work just like the kw-formals for lambda.
The #:rest match-pattern clause matches the list of arguments against match-pattern, which can be any pattern that can be used with match (not just an identifier).
The #:args-hash match-pattern clause matches the args-hash against match-pattern, which again can be any pattern that can be used with match.
The #:kws match-pattern #:kw-args match-pattern #:rest match-pattern clause matches the keywords, keyword-arguments, and by-position arguments (from keyword-lambda) against the 3 match-patterns.
The _ and else clauses recive any arguments, including keyword-arguments, but it can still go on to the next clause if the #:when condition is is false (or the #:unless condition is true).
The clauses starting with #:when and #:unless recive any arguments, (including keyword-arguments), but can still go on to the next clause if the #:when condition is false (or the #:unless condition is true).
It also allows you to use #:when and #:unless in the clauses.
keyword-case-lambda does not create a mutable-match-lambda-procedure, but it uses mutable-match-lambda-clause-append (which creates a normal immutable procedure), so it supports going to the next clause with mutable-match-lambda-next. (mutable-keyword-case-lambda creates a mutable-match-lambda-procedure)
Examples: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
syntax
(mutable-keyword-case-lambda clause ...)
syntax
(clause->proc/keyword-case-lambda clause)