[racket] Macros With Multiple Ellipsis
I have a macro that modifies define to perform some additional processing.
(define-syntax (define/test stx)
(syntax-case stx ()
[(_ (id arg ...) body ... #:test test-expr)
#'(define (id arg ...) body ... test-expr)]))
(define/test (my-fn a b c)
(print a)
(print b)
(print c)
#:test
(print 'test))
This works, but only if test-expr is *one* expression or wrapped in a begin
or something. I'd like the test-expr to be the same as the define body. I
wish I could write:
(define-syntax (define/test stx)
(syntax-case stx ()
[(_ (id arg ...) body ... #:test test-expr ...)
#'(define (id arg ...) body ... test-expr ...)]))
But I get a "misplaced ellipsis in pattern" error.
I could change the pattern to something like (body ...) #:test (test-body
...), but now the syntax of the macro has changed to include the extra
parenthesis.
Am I making a simple mistake? Or am I resigned to manually parsing out the
single test-expr into multiple forms in the template?
Thanks.
--
Talk to you soon,
Scott Klarenbach
PointyHat Software Corp.
www.pointyhat.ca
p 604-568-4280
e scott at pointyhat.ca
200-1575 W. Georgia
Vancouver, BC V6G2V3
_______________________________________
To iterate is human; to recur, divine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140108/869d7adf/attachment-0001.html>