www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Reading the ModuleInfo data?

I'd like to know if it is possible to get a pointer to the ModuleInfo  
object of the current module. I am asking because i want to do something  
like this:



module some.library;

template LibraryMixin()
{
   void func(char[] str)
   {
     someOtherFunc(str, currentModule.name); // HERE
   }
}



module my.program;
mixin LibraryMixin!();

int main(char[][] args)
{
   func("Hello, world.");
   return 0;
}



The line marked with “HERE” calls someOtherFunc(), and it should pass the  
name of the current module to it. As the function belongs to a mixin that  
is inserted into module my.program, that should be "my.program" or  
something similar, but *not* "some.library".

I could of course solve that with something like this:


module some.library;
template LibraryMixin(alias moduleName)
   // use the moduleName...

module my.program;
char[] modName = __FILE__;
mixin LibraryMixin!(modName);


But that requires this extra line i'd really like to avoid if possible, to  
make the use of some.library as simple to the user as possible.

Thanks & ciao
uwe
Jul 04 2005