Keyword "package" prevents from importing a package module "package.d"

Andrey Zherikov andrey.zherikov at gmail.com
Fri Nov 3 11:20:56 UTC 2023


On Friday, 3 November 2023 at 00:52:18 UTC, H. S. Teoh wrote:
> Supposedly you can do this:
>
> 	/* Original: */
>
> 	// pkg/mymodule.d
> 	module mymodule;
> 	... // code here
>
> 	// main.d
> 	import mymodule;
> 	void main() { ... }
>
> 	/* Split */
>
> 	// pkg/mymodule/pub_submod.d
> 	module mymodule.pub_submod;
> 	... // code here
>
> 	// pkg/mymodule/priv_submod.d
> 	module mymodule.priv_submod;
> 	... // code here
>
> 	// pkg/mymodule/package.d
> 	module mymodule;
> 	public import priv_submod;
>
> 	// main.d
> 	import mymodule;
> 	void main() { ... }
>
> Barring the issues listed above, of course.

I know how to do this with package.d but my question was about 
"package.d is bad design decision" - How would I do this 
refactoring without dedicated "main package file"?
Python, for example, has __init__.py as well



More information about the Digitalmars-d-learn mailing list