Andrew Wright's pattern matching package. Note that to use the macros in
normal compiled code it is not required to declare this unit as used. Only
if forms containing these macros are to be expanded at runtime, this
is needed.
-
- [syntax] (match EXP CLAUSE ...)
-
- [syntax] (match-lambda CLAUSE ...)
-
- [syntax] (match-lambda* CLAUSE ...)
-
- [syntax] (match-let ((PAT EXP) ...) BODY)
-
- [syntax] (match-let* ((PAT EXP) ...) BODY)
-
- [syntax] (match-letrec ((PAT EXP) ...) BODY)
-
- [syntax] (match-define PAT EXP)
-
Match expression or procedure arguments with pattern and
execute associated expressions. A Postscript manual is
available 21.
- [syntax] (define-structure (ID_0 ID_1 ... ID_N))
-
- [syntax] (define-structure (ID_0 ID_1 ... ID_N) ((ID_N+1 EXP_1) ... (ID_N+M EXP_M)))
-
- [syntax] (define-const-structure (ID_0 ARG_1 ... ARG_N))
-
- [syntax] (define-const-structure (ID_0 ARG_1 ... ARG_N) ((ARG_N+1 EXP_1) ... (ARG_N+M EXP_M)))
-
Macros for defining record structures that can be decomposed by match.
- (match-error-control [MODE])
-
Selects a mode that specifies how match... macro forms are to
be expanded. With no argument this procedure returns the current mode. A
single argument specifies the new mode that decides what should happen
if no match-clause applies. The following modes are supported:
-
- #:error
-
Signal an error. This is the default.
- #:match
-
Signal an error and output the offending form.
- #:fail
-
Omits pair? tests when the consequence is to fail in car
or cdr rather than to signal an error.
- #:unspecified
-
Non-matching expressions will either fail in car or cdr
or return an unspecified value. This mode applies to files compiled
with the unsafe option or declaration.
Note: match:structure-control is not available. Structures
defined by the macros provided in this unit are always implemented
as vectors. match:runtime-structures is also not available.
To use the pattern matching macros with the highlevel (syntax-case)
macro system, load the macro definitions with (include "match")
or (require-for-syntax 'match).