Using local import path
rikki cattermole via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Sep 9 01:25:40 PDT 2016
On 09/09/2016 8:08 PM, O/N/S wrote:
> Hi
>
> Example:
> I have a module called "a.b.c";
> and a second module called "a.b.c.d.e";
>
> For importing i can use
> import a.b.c;
> import a.b.c.d.e;
>
> or with local names
>
> import abc = a.b.c;
> import abcde = a.b.c.d.e;
>
> Question:
>
> Is it possible to use something similar like following
>
> import abc = a.b.c;
> import abc.d.e;
>
> which would be a combination of a local renamed and enhanced path?
> I tried and it doesn't, could be a wrong using...
>
> Thanks & Regards,
> Ozan
A bit of a misunderstanding of what is going on with import and packages
there.
In D there is no package import functionality that is implicit.
So by importing a.b.c you're importing a module, not a package.
This is key that it is a module and not a package. Because it is not
required to expose other modules.
Now to expose symbols to the importee via imports you will use public
import. A public import basically says, hey I know about these symbols
provided by another module but I want it accessible with mine.
But we have a special module called package.d which when used e.g.
a/b/c/package.d and imported as import a.b.c; which allows the emulation
of a package importation. But remember because of public imports it does
not have a special package symbol associated with it. Its just a plain
old regular module.
TLDR: no you cannot do what you were thinking.
More information about the Digitalmars-d-learn
mailing list