package.d

Leandro Motta Barros lmb at stackedboxes.org
Mon Dec 16 16:51:37 PST 2013


Hello,

I have some code using the old "all.d" idiom, which I am changing to use
the new "package.d" feature.

Originally, I had something like this:

// mylib/util.d:
module mylib.util;
class Foo { }

// mylib/all.d:
module mylib.all;
public import mylib.util;

// main.d:
import mylib.all;
void main()
{
   auto f = new mylib.util.Foo;
}

And this used to work. Now, I added a new file:

// package.d
module mylib;
public import mylib.util;

And changed the 'import' in the main one:

// main.d
import mylib;

void main()
{
   auto f = new mylib.util.Foo;
}

Now, the compiler complains:

main.d(5): Error: undefined identifier 'util'
main.d(5): Error: mylib.util.Foo is used as a type

Isn't this 'package.d' feature supposed to work just as the old 'all.d' and
'_,d' we used before?

(I see that I can use 'mylib.Foo' instead of 'mylib.util.Foo', but
http://dlang.org/module.html is clear saying that "[a]ll symbols from a
publicly imported module are also aliased in the importing module. This
means that if module D imports module C, and module C *publicly* imports
module B which has the symbol *bar*, in module D you can access the symbol
via bar, B.bar, and C.bar.")

I am using DMD 2.064 here.

Thanks,

LMB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20131216/76bc479a/attachment.html>


More information about the Digitalmars-d-learn mailing list