[racket] Extending syntax-parameters?

From: J. Ian Johnson (ianj at ccs.neu.edu)
Date: Tue Oct 16 21:56:57 EDT 2012

I have a syntax parameter that is bound to a transformer. I want to (at certain points) change the parameterization of this parameter to a new transformer that depends on the old one.

I can't do this:
#'(syntax-parameterize ([p (syntax-parser
                            [pat (some-combination-of (syntax-parameter-value #'p) pat))])])

Because the value fetched is the inner most one, but I want what it is currently.

I tried to be cute and create a table keyed by gensyms like so:

(define g (gensym))
#`(syntax-parameterize ([p-table (hash-set (syntax-parameter-value #'p-table)
                                           (syntax-parameter-value #'p))]
                        [p (syntax-parser
                             [pat (some-combination-of
                                    (hash-ref (syntax-parameter-value #'p-table) '#,g)

But it complains that 

write: cannot marshal value that is embedded in compiled code
  value: #<rename-transformer>

What is the right way to get this scope to work out, if possible?

Posted on the users mailing list.