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

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


BCS wrote:
> Reply to Sergey,
> 
>> AEon <aeon2001 at lycos.de> wrote:
>>
>>> BCS wrote:
>>>
>>>> Reply to AEon,
>>>>
>>>>> Last coding D 3.5 years ago. I wrote functions that would return
>>>>> the file handle. But such code no longer compiles under v1.030 (it
>>>>> worked under v0.118 though). Could someone please tell me how this
>>>>> may be fixed.
>>>>>
>>>> Can I assume that you are importing std.stream ?
>>>>
>>> Yes you can... because "File" works everywhere else.
>>>
>>> If that should make a difference, I am importing another module that
>>> itself imports:
>>>
>>> import std.c.stdio;
>>> import std.c.stdlib;
>>> import std.stdio;
>>> import std.path;
>>> import std.file;
>>> import std.string;
>>> import std.conv;
>>> import std.date;
>>> import std.stream;
 >>
>> From reading other people's code and Phobos sources I came to
>> conclusion that, long ago, imports were public by default.  They are
>> not anymore.  Imports are private by default, this may be your
>> problem.
>>
> 
> That is true. The change was not to far from v1.000

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?

To the aepar_file.d module I just added an explicit "import std.stream", 
even though aepar_global.d already imports that libarary:

     module aepar_file;
     import aepar_global;     // Global Variables, Libs etc.

     import std.stream;       // File, open(), close(), ...

And the compiler no longer shows the warning. IT WORKS! :). Thanks.


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?











More information about the Digitalmars-d-learn mailing list