Module name compile time constant?
Bill Baxter
dnewsgroup at billbaxter.com
Mon Apr 14 22:00:57 PDT 2008
Walter Bright wrote:
> davidl wrote:
>>
>> module abc.super.long.pack.awesome.mod;
>>
>> what if i need the string of "abc.super.long.pack.awesome.mod"
>> generally and don't want to copy paste differently in all my modules?
>
> alias abc.super.long.pack.awesome.mod foo;
I think he wants that full module name as a char[], though.
Is that what you want, Davidl?
Or do you just want to be able to say
import short.awesome; // aka "import abc.super.long.pack.awesome.mod"
If that's what you want you can create a module in short/awesome.d that
contains just:
module short.awesome;
public import abc.super.long.pack.awesome.mod;
But somehow I'm thinking you actually want to automatically get that
module name as a string.
How about going the other way around? Start with a string?
string foo = "abc.super.long.pack.awesome.mod";
mixin(import_module(foo));
where import_module is
string import_module(string name) {
return "import " ~ name ";" ;
}
If those don't answer your question you're gonna have to be more specific.
--bb
More information about the Digitalmars-d
mailing list