How to import & export modules
userTY
userTYbutno at nowhere.fi
Mon Nov 11 01:28:54 UTC 2019
On Sunday, 10 November 2019 at 23:53:22 UTC, Vinod K Chandran
wrote:
> Hi all,
> I am practicing D by writting a win API gui wrapper. I want to
> use a single module import to use this Gui lib. Say i have 10
> modules like--
> "App.d, Form.d, Button.d, Label.d, TextBox.d, ComboBox.d,
> ListBox.d, CheckBox.d, Panel.d, DateTimePicker.d"
> In Nim, i can import and export all these modules in a separate
> single module and then i only need to use that module. Say i
> have a special module named "GuiLib.nim" And inside that if i
> write like this--
> import
> App
> Form
> Button
> ....
>
> export
> import
> App
> Form
> Button
> ....
>
> Then in my main file, i only need to import the "GuiLib". How
> is this possible in D ?
You must use a module that has public imports.
Public imports are visible from the module that contain them but
most importantly from the module that imports the module
containing the public imports.
---
module all;
public import App, Form, Button;
---
---
module app;
import all; // can see App, Form and Button exported (public)
symbols
---
See the specifications [1] for more comprehenssive details.
[1]: https://dlang.org/spec/module.html#public_imports
More information about the Digitalmars-d-learn
mailing list