6.2.901.900
:match
(require colon-match) | package: colon-match |
syntax
(:match val-expr clause ...)
clause = [pat body ...+] | [pat (=> id) body ...+] | [pat #:when cond-expr body ...+]
like match, except that it allowes identifiers with colons in patterns to specify types.
For example the pattern x:num is equivalent to the pattern (? number? x).
(:match val-expr [pat body-stuff ...] ...) expands to (match val-expr [(:pat pat) body-stuff ...] ...).
Examples: | |||||||||||
|
match expander
(:pat pat)
a match expander that rewrites pat to change all of the identifiers written in colon notation
to a pattern that checks the type.
A pattern of the form id:type is rewritten to (type id), and then type is is a match expander that expands to something like (? type? id). This means that you can define your own ":match classes" by defining them as match expanders.
Examples: | |||||||||||||||||||
|
syntax
(define-:match-class id pred-expr)
defines id as a match expander that checks that the pattern satisfies pred-expr.
id can then be used in a colon-notation pattern.
Examples: | ||||||||
|