std.file.read implementation contest
Steve Schveighoffer
schveiguy at yahoo.com
Mon Feb 16 18:48:07 PST 2009
On Mon, 16 Feb 2009 16:36:52 -0800, Sean Kelly wrote:
> Andrei Alexandrescu wrote:
>>
>> I totally agree. The useful spec of std.file.read should be "reads the
>> file to exhaustion in a buffer and returns it"
>
> Okay, that's a fair definition. So the correct behavior for reading an
> unbounded stream should be an out of memory error? This would be
> entirely reasonable, but any failure conditions should be described as
> well.
Then why doesn't cp have a warning about copying /dev/random or /dev/
zero? I think it's enough to specify what it does (read the entire file)
and trust that people understand what they are doing when the attempt to
read an unbounded stream. The warning belongs with the stream, not with
the simple utility. It probably only takes once for the developer to
screw it up to learn ;)
But I guess it doesn't hurt...
-Steve
More information about the Digitalmars-d
mailing list