> On 13 Aug 19, at 7:03 PM, Jonathan Simpson <jjsim...@gmail.com> wrote: > > In the following magic code, a new function(called a named query in magic) > tga-image is defined and later used inside the definition of the function > test-scope. The issue is that tga-image is an unbound identifier in > test-scope. If tga-image is used outside of a function there isn't a problem > because the syntax object passed to use has the binding. What I would like to > do is define tga-image at the top level.
You might consider the technique described here, including the `find-unique-var-ids` function: https://beautifulracket.com/basic-2/variables-and-input.html <https://beautifulracket.com/basic-2/variables-and-input.html> Since you're using `brag`, you can wrap your future identifiers in, say, an `id` rule that you splice away in the grammar. So your parse tree ends up the same, but now that `id` rule leaves a residue as a syntax property. Then, as part of your `#%module-begin` prep work, you can use this property to pull out the identifiers and write them into the top level of your new module as `define` expressions (with dummy values, that would get replaced later with `set!`). There may be a way of accomplishing the same thing more elegantly with syntax lifts and captures. Like the lost city of El Dorado, I searched for this beauty, but expired on the jungle floor before discovering it. Since then, however, many people smarter than me have seen that page, so by Cunningham's Law, if there were a better method, I probably would've been told by now. -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/DC4EE1B4-5164-43CB-89D8-E750F15B1A68%40mbtype.com.