Re: New draft (#3) of SRFI 262: Extensible pattern matcher
Daphne Preston-Kendal 04 Nov 2025 17:10 UTC
Thank you, Arthur.
With the release of draft 3 of the SRFI comes also the release of v0.875 of the sample implementation, extensible-match.
Aside from updates to reflect changes in the SRFI, this version removes the dependencies on SRFI 151 (in favour of the R6RS native bitwise operations library) and SRFI 133 (in favour of a home-grown implementation of copy-on-write semantics for vectors). It improves expansion times by memoizing the construction of the decision tree. Complex patterns will also generate significantly better code due to a bug fix in the code generator, and some simpler pattern sets will also avoid needless deconstructor calls until they are known to be needed.
The following user-visible bugs have now been fixed, and regression tests added to alert to any potential recurrence:
• disjointed variables were not correctly bound to transformers for erroneous syntax use when using match-define and match-letrec*
• the sequence name of seq/unordered patterns was accidentally in scope for expressions evaluated within the subpatterns; it isn’t any more, in accordance with the SRFI
Thanks to a bug report from Zhu Zihao, this version should also work on hypothetical Scheme implementations that support SRFI 213 but don’t guarantee that the hash values from symbol-hash and equal-hash are in the nonnegative fixnum range. This arose when he was producing a sui generis port of extensible-match to Unsyntax; I don’t expect it to affect users on any ‘normal’ implementation of the R6RS.
Get it here: <https://codeberg.org/dpk/extensible-match/archive/v0.875.tar.gz>
See the commit log with all changes from the previous version: <https://codeberg.org/dpk/extensible-match/compare/v0.75.1..v0.875>
Daphne
On 4 Nov 2025, at 17:40, Arthur A. Gleckler <xxxxxx@speechcode.com> wrote:
> I've just published draft #3 of SRFI 262. It was submitted by Daphne Preston-Kendal, author of the SRFI.
> Here are Daphne's comments on the draft:
>
> This draft adds an example of how the SRFI 250 cursor interface can be used with seq/unordered to implement a hash-table pattern, notes several potential future extensions which might be made by follow-up SRFIs, and attempts to more clearly formulate the priority rule for seq/unordered matches. The apply pattern has been renamed to =>. Several minor corrections and other improvements have also been made.
> Please take note of the three new issues (bikeshedding the name of seq/unordered; suggestion to add a formal semantics; and MNW’s concern about binding the underscore), and the proposal for an alternative extended ellipsis syntax in issue 7.
> Here is the commit summary:
> • Add "match" as library name.
> • Update to reflect improvements in the sample implementation
> • Don’t allow letrec/define continuations to be invoked more than once
> • Credit Zhu Zihao
> • Note the sample impl no longer needs SRFI 133
> • Correct a silly mistake in an example
> • Extend MNW’s acknowledgement
> • Cite ‘Writing Macros in Continuation-Passing Style’ paper
> • Remove a pleonasm
> • Postpone pattern guards to a future extension
> • Mark issues as resolved/no action taken, expand on ext ell issue
> • Standardize on hyphenated form of left-hand side and right-hand side
> • Note it would be better to get rid of the make- convention
> • More examples
> • Note examples issue as resolved
> • Improve hash-table pattern example
> • Allow `seq` and friends to terminate early in case of positive match
> • Set line-height explicitly
> • Add section on future extensions
> • Delete an accidental word
> • Rename ‘apply’ to ‘=>’, introduce the term ‘transformation pattern’
> • Link HaMLet S
> • Reword the pattern guard section
> • Copy-edit co-patterns
> • Clarify priority rule for `seq/unordered`
> • Add issue: Bikeshed the name of `seq/unordered`
> • Add issue: Formal semantics
> • Acknowledge Arthur
> • Improve wording of priority rule
> • Add issue: var patterns/binding the underscore
> • Improve wording of var pattern issue
> • Typo correction
> • hash-table pattern example accidentally depended on a scoping bug
> • Reword the rest pattern priority rule
> • Typo in an example
> • Unresolve `seq/unordered` issue
> • Add missing hyphen
> • Publish third draft.
> Here's the diff:
> https://github.com/scheme-requests-for-implementation/srfi-262/compare/draft-2..draft-3
> Regards,
> SRFI Editor