From: <wol...@ex...> - 2014-02-26 21:41:45
|
> Is it possible to use function-lookup on a module that has been imported at runtime using util:import-module? > In the below example I would call module-a:func() and expect module-b:some.funky.function() to be executed. > I do not know the method in module-b until runtime. I can’t exactly remember why, but I think function-lookup cannot see a module imported dynamically via util:import-module. In the templating module, I use the following approach, which has the advantage of avoiding the non-standard util:import-module function: I have a main module, which knows all modules to be used by the application and imports them. In this main module, I create an inline function which calls function-lookup. This inline lookup function is passed to the templating module as a function parameter. Because of the closure, the inline function will be in the context of the module in which it was created and has access to any module imported there. Wolfgang |