(chibi match) other enhancements
-
Add
beginsuch that(begin a b)matches whata bmatches. This allows a pattern like(or (begin "foo" "bar") (begin "bar" "foo"))to match either"foo" "bar"or"bar" "foo". -
Named subpatterns. SRFI 159/166 allows you to define a named formatter, but there is no analogous way to define a named pattern for reuse in the same or different
(chibi match)patterns. There should be. -
Simple types. It would be good to reserve symbols
number? string? symbol? boolean?to match any number, any string, etc. These are equivalent to?patterns but shorter and simpler. -
Interleave. This is an advanced feature and I wouldn't weep if it were left out, but it can be very useful. The pattern
(interleave (begin "foo" "bar" "baz") 'x ...)matches anything with"foo" "bar" "baz"in that order with instances ofxbefore, after, or in between.
- It sounds like an extension to unquote-splicing. We could special case:
,@(or a b)for splice either a or b, but I'm not sure this is a good idea. - This will cause issues with hygiene, since you are effectively "importing" non-local identifiers. On the other hand, if you don't care about the identifiers you can just use
equal?or some other imported predicate. - Two characters shorter for a non-general extension isn't compelling. People would have to remember which predicates had this special treatment.
- I'd rather add a general extension for custom patterns.