Thanks! That was much easier than I was expecting.
For posterity, here is some working code but be warned that I don't know
whether 'module is the best expansion context to use. But this is a toy
example anyway.
#lang racket
(define-syntax (collect stx)
(syntax-case stx (define-values)
[
The main trick in this case is to recognize `define-values` (which is
what `define` expands to) instead of `define`. That's because
`define-values` propagates syntax arming to its identifiers and
right-hand side, which means that your macro is allowed to pull it
apart.
You'll also need to use an e
The following code produces '(1 2 3 4)
(define-syntax (collect stx)
(syntax-case stx (define)
[(_ (define id val) rest ...)
#'(let ([id val])
(collect rest ...))]
[(_ (macro arg ...) rest ...)
(syntax-local-value #'macro (lambda () #f))
(let ([expanded (local-expa
3 matches
Mail list logo