A variable reference produced by `(#%variable-reference)` can serve as the starting point for reflective operations on modules. Specifically, use
(variable-reference->module-path-index (#%variable-reference)) to get a reference to the enclosing module, and use `module-path-index-join` on that value and "../core/internat.rkt" to get a reference to the "../core/internat.rkt" module. At Thu, 9 Feb 2017 12:25:35 +0000, Erich Rast wrote: > Out of general curiosity I'm still trying to figure out how a dynamic > plugin system would work. So now I'd like to namespace-attach-module > for all modules that the current module imports (and their submodules), > and then namespace-require them. > > The problem is that I don't know how to attach modules required by > relative paths and with prefix-in, because I don't know their symbolic > name (if they have one). What I'm attempting is this: > > (require racket/gui/base > racket/runtime-path > gregor > (prefix-in internat: "../core/internat.rkt")) > > (define-runtime-path notetaker > "../notetaker/notetaker-main.rkt") > > > (define notes-panel% > (let ([ns (make-base-empty-namespace)]) > (namespace-attach-module (current-namespace) > 'racket/gui/base > ns) > (namespace-attach-module (current-namespace) > 'gregor > ns) > (namespace-attach-module (current-namespace) > "../core/internat.rkt" > ns) > (parameterize ([current-namespace ns]) > (namespace-require 'racket/gui/base) > (namespace-require 'gregor) > (namespace-require "../core/internat.rkt") > (dynamic-require notetaker 'notes-panel%)))) > > where the respective require for internat is left out in > notetaker-main.rkt, since the dynamically required module needs the > instance of the module *from the calling module's namespace*, not a > separate copy. But this fails for "internat.rkt" - and it also will not > create the right module path in the compiled distribution binary, it > seems. > > Is there an internal symbolic name for the module required with > prefix-in and relative path? > > Best, > > Erich > > -- > 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. -- 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.