[plt-scheme] Extending macro pattern syntax

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Jan 31 15:41:25 EST 2009

On Jan 31, James Coglan wrote:
> Also, I just noticed this does not work:
> 
> (define-syntax infix-ellip
>   (syntax-rules ()
>     [(_ (name value) ... fn ignore ...)
>       (let ([name value] ...)
>         (fn name ...))]))
> 
> mzscheme complains of more than one ellipsis in the pattern (which I
> gather is what R6RS mandates), but there's no reason I can see that
> this should not be allowed to match, say, the following:
> 
> (infix-ellip (a 1) (b 2) * 5 'ignore)
> 
> Can macros be used to support this or is it impossible?

It's possible -- for example, the `match' form can deal with it:

  (match '(infix-ellip (a 1) (b 2) * 5 'ignore)
    [(list _ (list name value) ... fn ignore ...)
     (list name value)])

But it's not clear that it's a good idea to allow that in macro
patterns: using such macros can be more confusing than usual.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.