Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
January 16, 2014 package.d imports | ||||
---|---|---|---|---|
| ||||
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"); } |
January 16, 2014 Re: package.d imports | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lemonfiend | Sorry, that's --- pack/package.d and --- pack/sub.d |
January 17, 2014 Re: package.d imports | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lemonfiend | 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 |
January 17, 2014 Re: package.d imports | ||||
---|---|---|---|---|
| ||||
Posted in reply to Colden Cullen | > I think this is what you are looking for: http://dlang.org/changelog.html#import_package
What an odd place to put it..
Too bad, it doesn't mention anything about calling the functions like in my example, and why some do/don't work. I'd hoped for more.
|
January 19, 2014 Re: package.d imports | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lemonfiend Attachments:
| Hi!
I made similar questions here a month ago, but also couldn't get definitive answers. I just sent a message about this to the main D forum. Let's see if we have better luck there :-)
Cheers,
LMB
On Fri, Jan 17, 2014 at 5:39 PM, Lemonfiend <lemon@fie.nd> wrote:
> I think this is what you are looking for: http://dlang.org/changelog.
>> html#import_package
>>
>
> What an odd place to put it..
>
> Too bad, it doesn't mention anything about calling the functions like in my example, and why some do/don't work. I'd hoped for more.
>
>
|
Copyright © 1999-2021 by the D Language Foundation