[plt-scheme] Extending macro pattern syntax
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!