On Thursday, 16 January 2014 at 15:46:01 UTC, Lemonfiend wrote:
The following behavior seems odd to me. Could anyone explain why it works as it does? (Does package.d have a page on dlang.org?)

--- main.d
module main;

void main()
{
        test1();
        test2();
}

void test1()
{
        import pack;

        // works
        foo();

        // works, did not expect it to
        pack.foo();

        // does not work: Error: undefined identifier 'sub'
        //pack.sub.foo();
}

void test2()
{
        import pack.sub;

        // works
        foo();

        // works, even more unexpectedly
        pack.foo();

        // works
        pack.sub.foo();
}

--- package/pack.d
module pack;

public import pack.sub;

--- package/sub.d
module pack.sub;

void foo()
{
        import std.stdio;
        writeln("hello");     
}

I think this is what you are looking for: http://dlang.org/changelog.html#import_package

Reply via email to