Packages / imports & references between modules

Robert M. Münch robert.muench at saphirion.com
Sun Apr 28 11:12:50 UTC 2019


On 2019-04-27 16:30:48 +0000, Adam D. Ruppe said:

> This will never work in D. The module needs to work by itself. It can 
> see public imports from another module it itself imports:
> 
> module A.c;
> 
> import A; // thanks to this, it can see a `public import A.a;` from the 
> A package..
> 
> 
> But without that explicit import, it cannot see anything outside 
> itself. You might be able to get away with listing the `public import`s 
> in package.d, and then just `import A;` in each individual module 
> though.

One more problem now showing up, when I do this:

A/a.d
	module A.a;
	struct myStruct;

A/b.d
	module A.b;
	struct myStruct {...}

A/c.d
	module A.c;
	import A;
	struct myOtherStruct {
		myStruct ms;
	}

I now get an error in file A/c.d that a.a.myStruct conflicts with 
a.b.myStruct. Looks like these symbols are different for D. Is there a 
way to tell D that one is only a forward reference and is the same when 
D sees the struct declaration later?

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



More information about the Digitalmars-d-learn mailing list