On 2009-03-17 20:26:16 -0400, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> said:
Interesting. Should I do the same in phobos?
stdout("wyda");
I'd like that particularly because write() is too common a name to
place at namespace level for my taste. So then we'd have:
stdout("wyda"); // no newline
stdout("wyda\n"); // newline but no flushing on binary stream
stdout("wyda", newline); // write'n'flush
stdout.writeln("wyda"); // same
If we go that route I'll even drop writeln and rely on passing newline.
For formatting there'd be stdout.format and stdout.formatln or
something.
Seems nice. Can this work symmetrically for stdin?
int i;
stdin(i); // reads an integer and place it in i.
That would make things interesting, as with some streams you could use
the same code to serialize and unserialize a data structures.
stream(x, y, z); // either write or read the values depending on the
stream.
This reminds me of boost serialization which use a similar trick
allowing you to have a single function template to both serialize and
unserialize a given data type.
But that probably couldn't work with the standard text stream types.
--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/