chibi-scheme icon indicating copy to clipboard operation
chibi-scheme copied to clipboard

(chibi match) other enhancements

Open johnwcowan opened this issue 7 years ago • 1 comments

  1. Add begin such that (begin a b) matches what a b matches. This allows a pattern like (or (begin "foo" "bar") (begin "bar" "foo")) to match either "foo" "bar" or "bar" "foo".

  2. 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.

  3. 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.

  4. 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 of x before, after, or in between.

johnwcowan avatar Apr 22 '19 15:04 johnwcowan

  1. 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.
  2. 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.
  3. Two characters shorter for a non-general extension isn't compelling. People would have to remember which predicates had this special treatment.
  4. I'd rather add a general extension for custom patterns.

ashinn avatar Jul 06 '20 05:07 ashinn