On Monday, 27 February 2017 16:40:50 UTC-5, Matthew Butterick wrote:
> Is there a simple way to lift a `require` form to the top level of a module?
> i.e., in the example below, is there something that would replace
> `WHAT-MAGIC-GOES-HERE?` to make it work?
> I understand that `syntax-local-lift-expression` won't work.
> But `syntax-local-lift-require`, as best I can divine, needs you to furnish a
> particular identifier as the second argument, and incurs other housekeeping
> with scopes. So, though I'm not really sure what it's for, I'm pretty sure
> it's not for this.
It appears to be for `local-require` behaviour: being able to use the required
identifiers locally in the syntax object you give it.
> (FWIW `syntax-local-lift-module-end-declaration` didn't work either.)
> #lang racket
> (define-syntax (lifted-require stx)
> (syntax-case stx ()
> [(_ spec) (WHAT-MAGIC-GOES-HERE? #'(require spec))]))
> (let ()
> (lifted-require math/number-theory))
If you want that to be equivalent to having `(require math/number-theory)` at
the top-level then I'm not sure the precise semantics: should it affect the
meaning of already-transformed code from before that `lifted-require` was
encountered? Recall that `requires` are noted before expansion of other forms,
so, e.g., this works:
divides? ; Even though the require for this appears after
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
For more options, visit https://groups.google.com/d/optout.