import with renaming and public import inside module

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Apr 28 08:57:15 PDT 2014


On Monday, 28 April 2014 at 00:52:50 UTC, ketmar wrote:
> module my.module;
> public import other.module;
>>
> module mainprogram;
> import my.module;
>
> now i can access other.module symbols without qualifiers
>
>
> and another case:
> module mainprogram;
> import zmod = my.module;
>
> now i CAN'T access other.module symbols without qualifiers. the 
> only way to access 'em is to use horrible 
> 'zmod.other.module.symbol', which completely defeats my 
> purposes for public imports in my.module.

`zmod.symbol` works, too.

> can i use import renaming, but still access my.module public 
> imports as if there was no renaming?

I don't think so. The point of the renamed import is that you 
have to use the new name. If you want the new name to be 
optional, import the module twice:
     import my.module;
     import zmod = my.module;
This way both `symbol` and `zmod.symbol` work.

>
[...]
>
> the question is: is such behaviour of 'import' intentional, or 
> this is just bug and it will be fixed eventually?

As far as I can see, everything works as intended.


More information about the Digitalmars-d-learn mailing list