At Sun, 21 Jan 2018 17:43:04 -0500, Matthew Butterick wrote: > I have a macro that produces code for a module expression, roughly like so: > > #'(module mod racket/base > . BODY-EXPRS) > > I'd like to `parameterize` the BODY-EXPRS as a group, roughly like so: > > #'(module mod racket/base > (parameterize ([param val]) > . BODY-EXPRS)) > > But — my BODY-EXPRS might contain things like `require` and `provide`. They > need to be at the top level. So I want the body of the `parameterize` to be > spliced into the surrounding context. > > I assume this is a job for `racket/splicing`. But even though it contains a > whole range of `splicing-let···` forms and a `splicing-syntax-parameterize`, > there is no `splicing-parameterize`. > > Is there a different way to get this done? (Short of imperatively setting the > parameter, which is my current workaround) Or is there some formidable reason > that `splicing-parameterize` doesn't exist?
I think I've never considered `splicing-parameterize` because parameters can be mutated, but a `splicing-parameterize` form does make sense. I imagine that it would be implemented by creating a parameterization once, then pushing the parameterization over multiple expressions using `call-with-parameterization`. Beware that a `splicing-parameterize` around a `require` could be misleading. The `require` form just declares a dependency, but a programmer who sees `splicing-parameterize` around `require` might expect the parameterize to somehow wrap the dynamic loading of the required module (and there's no way to do that, partly because the required module might already be loaded). Then again, the same confusion is possible with an imperative parameter assignment written before a `require` in a module body. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.