finish function for output ranges

José Armando García Sancio jsancio at gmail.com
Sun Aug 12 10:33:06 PDT 2012


On Sat, Aug 11, 2012 at 4:29 PM, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> For files, finish() should close the file (or at least flush it - unclear on
> that). I also wonder whether there exists a better name than finish(), and
> how to handle cases in which e.g. you finish() an output range and then you
> put more stuff into it, or you finish() a range several times, etc.
>

As another data point, std.log has a Logger interface which defines
log(...) and flush (...) so this fits perfectly into this output range
design. Here are the current signatures:

shared void log(const ref LogMessage message);
shared void flush();

finish would be a weird name for 'interface Logger' because it is not
a final operation. For what it is worth, Java's OutputStream has the
following:

void write(...) // overloaded three times
void flush() // "Flushes this output stream and forces any buffered
output bytes to be written out."
void close() // "Closes this output stream and releases any system
resources associated with this stream."


More information about the Digitalmars-d mailing list