How to import & export modules

Mike Parker aldacron at gmail.com
Mon Nov 11 06:34:40 UTC 2019


On Monday, 11 November 2019 at 01:28:54 UTC, userTY wrote:

>
> import all; // can see App, Form and Button exported (public) 
> symbols
> ---

The approach of using an "all" module is an old hack that is no 
longer necessary. Today, the way to approach is to use a "package 
module".

https://dlang.org/spec/module.html#package-module

Given a package "mylib" containing multiple modules, create a 
file "mylib/package.d". Use the package name as the module name 
and follow it with your public imports:

module mylib;

public import mylib.foo, mylib.bar, mylib.baz;

Then users of the package can simply:

import mylib;




More information about the Digitalmars-d-learn mailing list