Passing file handles from functions? (Changed since dmd v0.118)

AEon aeon2001 at lycos.de
Thu Sep 18 03:49:03 PDT 2008


Lars Kyllingstad wrote:

> 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

Ah... I have noted how "messed up" my namespace was. Back then I ported 
the parser code (AEstats) directly from ANSI C and v0.118 seems to have 
been tolerant enough to let me use "import" pretty much the way I was 
using "include" under C. You are right, I also prefer to have things as 
clearly implemented as possible.

What surpised me, after removing the global import of libs, was that my 
modules did not seem to need any of the libs... I find that a bit strange.


Question: Will dmd make it pretty clear when it needs some library 
included? I.e. the compiler shows a warning / error?

Because that way I could minimize the libs to include on a per module basis.


Thanx for everyone being pacient with me, alas all the examples I have 
been reading are all in one module, not distributed into many modules as 
part of a project.

AEon


More information about the Digitalmars-d-learn mailing list