Re: [Scheme-reports] match.scm
Peter Kourzanov 15 Dec 2010 19:32 UTC
Alex,
> > * missing struct/records support? I think we should specify it,
> > and let implementations decide on its efficient representation
>
> These are actually commented out in the source. The upstream
> chibi-scheme version has support for matching SRFI-99 records.
Should I look here?
http://code.google.com/p/chibi-scheme/source/browse/lib/chibi/match/match.scm?r=e29de01c617da072a938de874d2272558ebe2746
>
> > * at some point, it does vector->list for matching inside
> > quasiquote. Isn't it a bit inefficient?
>
> Vectors in general are rare to match against - a lot of matching
> libraries use that trick for matching even outside of quasiquote.
Not in numeric/linear algebra code. But I agree, its a neat trick,
which I have also used at some point to get pattern matching to
work using pure R5RS syntax-rules matcher ;-) But I have since
abandoned this idea as matching for particular values at large (but
bounded offsets) inside vectors is then very inefficient.
> It's easy enough to optimize if you feel the extra code is worth
> it.
Agreed.
>
> > * are nested ellipses supported? Looks like they are quite
> > useful...
>
> Please read the comment in the source regarding this - they are
> intentionally disabled.
Couldn't find it in the sources... Any hints?
>
> Nested tree patterns aren't disabled, though,
>
> > * (? predicate) matching is a bit ugly when you use (? number?).
> > Reminds me of Bigloo/Queinnec's matcher
>
> Alternate syntax suggestions are welcome.
Actually, I would like to propose
________________________________________________________________________
(predicate? : accessor1 = pattern : accessor2 = pattern ...)
________________________________________________________________________
where accessorN can be something like a lambda abstraction
(lambda (x) x) or (fun args ...) returning a singular
function expecting matched data. Predicate? can be any
singular function returning boolean.
So, the dispatch is this case is better on the second form (:),
rather than the first (?)...
>
> > * where are guards?
>
> You can combine predicates and/or use the failure continuation.
Isn't this too verbose? Don't we want to abbreviate (this very common
case) in a manner already pretty much accepted by ML, Haskell, Scala
and R6RS compile-time pattern-matcher?
>
> > * matching numbers: we need to use (=) to match them, not equal?
> > (or eqv? and eq?)
>
> Do we? :)
>
Typing. A good example: 42+0.0 should match both 42.0 and 42.
And then lets have n+k patterns;-)
Pjotr Kourzanov
_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports