Module name compile time constant?

davidl davidl at 126.com
Mon Apr 14 23:44:59 PDT 2008


在 Tue, 15 Apr 2008 13:00:57 +0800,Bill Baxter  
<dnewsgroup at billbaxter.com> 写道:

> 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

Yes, i want the string. But I don't want to modify the module part to  
manually defined strings
I want some magic of module.name to get the current module name in compile  
time string form.

-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/



More information about the Digitalmars-d mailing list