[r6rs-discuss] Why can ... and _ not be literals?
On Sun, 24 Jun 2007, AndrevanTonder wrote:
> There are advantages in [allowing ... as a literal], though. Here is
> the germ of a simple pattern matcher (not tested):
>
> (define-syntax matches?
> (syntax-rules (...)
> ((_ x ())
> (null? x))
> ((_ x (y ...))
> (and (list? x)
> (forall? (lambda (z) (matches? z y))
> x)))
> ((_ x (y . z))
> (and (pair? x)
> (matches? (car x) y)
> (matches? (cdr x) z)))
> ((_ x id) #t)))
>
> (matches? '((1 2) (3 4 5))
> ((x ...) ...)) ==> #t
>
> It seems a pity to force someone to use syntax-case for this kind of thing
> when syntax-rules would otherwise be adequate.
Agreed.
David
Received on Tue Jun 26 2007 - 00:09:35 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:01 UTC