On 5/13/2012 12:57 PM, Era Scarecrow wrote:
On Sunday, 13 May 2012 at 19:43:19 UTC, Walter Bright wrote:
On 5/13/2012 9:39 AM, Stewart Gordon wrote:
It seems that the main obstacle is rewriting the relevant methods in
std.stream. The current implementation doesn't make sense anyway - reading
the entire contents of a file is certainly not the way to generate a hash or
string representation of the stream. I'm thinking the hash should probably be
the stream handle, and the string representation could perhaps be the full
pathname of the file. Of course, what it should be for non-file streams is
another matter. (This would be a change at the API level, but when the API's
as fundamentally flawed as this....)
I'd like to see std.stream dumped. I don't see any reason for it to exist that
std.stdio doesn't do (or should do).
The only reason it's there at the moment is for backwards compatibility.
Recently in my own code I've started making use of std.stream, mostly creating
temporary string streams to test IO in functions that would otherwise need
actual files for unittests.
I suggest switching over to a range interface. Then, your code need not care if
it is getting input from files, arrays, or any containers. Same for output. That
means you can use arrays to unittest it, or write your own mock input/output ranges.
Glancing over std.stdio, I only see specific file access functions and routines.
If I'm doing the wrong approach please correct me now.
std.stdio's support for ranges needs some improvement.