status: draft (2025-05-07)
keywords: Pattern Matching
See also SRFI 200: Pattern Matching, SRFI 204: Wright-Cartwright-Shinn Pattern Matcher, SRFI 241: Match — Simple Pattern-Matching Syntax to Express Catamorphisms on Scheme Data, and SRFI 257: Simple extendable pattern matcher with backtracking.A pattern matching form which can operate on arbitrary Scheme values is defined. It conforms to the following design principles.
The syntax of patterns is declarative. The syntax is extensible in the same way that Scheme’s procedural syntax is extensible by macros.
For most use cases, the use of the pattern matcher should produce code which is essentially as efficient at run time as equivalent procedural Scheme code would be, assuming a moderately optimizing Scheme implementation. This applies only when the equivalent code is also equivalently correct in terms of handling of error cases (i.e. including all type checks done automatically by the pattern matcher). However, using extension syntax should not cause this principle to be violated (provided the extension syntax is appropriately implemented).