Passing file handles from functions? (Changed since dmd v0.118)
Lars Kyllingstad
public at kyllingen.NOSPAMnet
Thu Sep 18 03:28:32 PDT 2008
AEon wrote:
> Pardon my ignorance, this is only day 3 of me reading up on D again, but
> would that mean I have to place the "same" list of library imports into
> every module I use, instead of defining such a list in one "central"
> module, that is then imported by all the other modules?
>
> [...]
>
> So my "style guide" question?
>
> Should I refrain from using a global library include module
> (aepar_global.d), to instead include the libs on a per module basis,
> including only those libs the functions actually need? Or is there some
> other way?
If you use the *same* imports in every module, perhaps it makes sense to
create a module that imports them all. To do this, you use the 'public
import' statement, i.e. in aepar_global.d you write
public import std.c.stdio;
public import std.c.stdlib;
...
However, most of the time this is not true, at least not in my
experience. I think it's better to keep the namespace clean and tidy by
using only the imports one actually needs in each module. Private
imports are the default, as Sergey pointed out.
-Lars
More information about the Digitalmars-d-learn
mailing list