> On Jul 15, 2016, at 12:22 AM, Jack Firth <jackhfi...@gmail.com> wrote: > > But I'm hitting scope issues - I'm not sure hot to make the redefinitions of > func available in (body ...) in a (with-foo func body ...) use, naively > adding the require imports fails to bring them into scope. Various > combinations of using syntax/loc and datum->syntax on the require statement, > the require submod path, and/or the body are all failing to do what I want.
How are your other macros defined? As far as I know, submodules provide things as symbols, without any lexical context, and that the require form is what introduces the scopes. So (if I'm right; I might not be) these scope issues are probably independent of how the submodule itself is defined? So one thing you can do is declare the submodule the normal way, without the macro, and see how your other macros interact with it. > How can I achieve this? Is there a better way to try and do this? For something like this I wouldn't use submodules, simply because I hadn't thought of it. Also submodules can only be used at the module-top level, not within an internal definition context, which probably means define/foo could only be used at the module-top level as well. Maybe that's fine. What I've done for things like this before is use non-lambda define-syntax bindings and syntax-local-value. Although, the scopes might make that more complicated, and a submodule solution could be simpler. > On Jul 15, 2016, at 1:54 AM, Jack Firth <jackhfi...@gmail.com> wrote: > > The macros don't use the defined modules themselves, the runtime expressions > wrapped by `with-foo` do. A runtime require is definitely what I'm looking > for. I've made some progress where `with-foo` is implemented basically like > this: > > (define-syntax-parser with-foo > [(_ foo-defined:id body ...) > #`(let () > (local-require > #,(syntax-local-introduce > #`(submod "." foo foo-defined))) > body ...)]) > > But when I attempt to use it, e.g. (with-foo func (helper1 ...)), I get the > error "helper1: identifier's binding is ambiguous in context" which I'm > guessing is because syntax-local-introduce is doing quite what I want with > scopes. What was the complete program that produced this error? I mentioned in my earlier email that this definition worked in my small example in the case where it was the only thing doing this scope stuff. So what were the other macros that interacted to give you the ambiguous binding error? Alex Knauth -- 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.