[plt-scheme] macros: incompatible ellipsis match counts
I was playing around with macros and am having trouble understanding
whats going wrong here. This macro works
(define-syntax foo2
(syntax-rules ()
((_ (z ...) f ...)
(begin
(begin z f ...) ...))))
(foo2 (1 2 3) 4 5 6)
The macro stepper says it evaluates to
(begin (begin 1 4 5 6) (begin 2 4 5 6) (begin 3 4 5 6))
But if I put another ... after (z ...) f ... then things break.
(define-syntax foo3
(syntax-rules ()
((_ ((z ...) f ...) ...)
(begin
(begin
(begin z f ...) ...)
...)
)))
(foo3 ((1 2 3) 4 5 6))
syntax: incompatible ellipsis match counts for template in: ...
Somehow this works if I don't have the ... after f, only using the ...
after the inner-most begin to match all the parts.
(define-syntax foo3
(syntax-rules ()
((_ ((z ...) f ...) ...)
(begin
(begin
(begin z f) ...)
...))))
Which the macro stepper says is
(begin (begin (begin 1 4) (begin 2 5) (begin 3 6)))
Which makes sense but that only works if the z's and f's have the same
arity. If I use
(foo3 ((1 2 3) 4 5))
then it breaks:
syntax: incompatible ellipsis match counts for template in: ...