[racket] Something to achieve "define-syntax-parameter-for-syntax" or "set!-for-syntax"?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Jan 5 13:32:44 EST 2014

It is an unusual way to break syntax but I can't think of a serious drawback off the top of my head. (I am sure Ryan and Matthew can think of one.) Does it pass your test cases? 


On Jan 5, 2014, at 1:21 PM, Sean Kanaley wrote:

> Ha!  The below solution is a macro-making macro that re-syntaxifies "params ..." to "belong to" the inner macro:
> 
> (define-syntax-rule (make-commands name params ...)
>   (define-syntax (name inner-stx)
>     (syntax-case inner-stx ()
>       [(_ (c f) (... ...))
>        (with-syntax ([(ps (... ...)) (datum->syntax inner-stx (syntax->datum #'(params ...)))])
>          #'(list (cons (symbol->string 'c)
>                        (λ (ps (... ...)) f))
>                  (... ...)))])))
> 
> I'm not sure if this is the canonical solution, but nevertheless I think it's pretty awesome that this is possible and seems to work.
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.