[r6rs-discuss] Why can ... and _ not be literals?
David Van Horn
dvanhorn at cs.brandeis.edu
Tue Jun 26 00:09:35 EDT 2007
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 (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.
More information about the r6rs-discuss