www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - FILE * ?

reply Arcane Jill <Arcane_member pathlink.com> writes:
From the docs...

#   void fwritef(FILE* fp, ...);
#       Same as writef, but output is sent to the stream fp instead of stdout.

Shouldn't Phobos be encouraging the use of std.stream?

Shouldn't Phobos be discouraging the use of fopen(), and other C wrappers where
sufficient or better D functionality exists?

I don't want to percieve D as a convenient way to call C functions. fopen() is
not OO and it is not safe. The stream does not close if an exeception is thrown
between fopen() and fclose(). It is possible to forget to call fclose().
fclose() will crash if you call it twice. I humbly suggest that fwritef() be
removed, and re-inserted as a member function of std.stream.

Jill
Jul 09 2004
parent "Walter" <newshound digitalmars.com> writes:
"Arcane Jill" <Arcane_member pathlink.com> wrote in message
news:cclipj$1imt$1 digitaldaemon.com...
 From the docs...

 #   void fwritef(FILE* fp, ...);
 #       Same as writef, but output is sent to the stream fp instead of

 Shouldn't Phobos be encouraging the use of std.stream?

 Shouldn't Phobos be discouraging the use of fopen(), and other C wrappers

 sufficient or better D functionality exists?

 I don't want to percieve D as a convenient way to call C functions.

 not OO and it is not safe. The stream does not close if an exeception is

 between fopen() and fclose(). It is possible to forget to call fclose().
 fclose() will crash if you call it twice. I humbly suggest that fwritef()

 removed, and re-inserted as a member function of std.stream.

I wrote std.format.doFormat() so it could be hooked up to anything - both FILE*'s and streams, as well as generating formatted strings. See std.string.format() for the latter.
Jul 09 2004