retard wrote:
Mon, 30 Nov 2009 21:06:21 +0800, KennyTM~ wrote:
On Nov 30, 09 19:01, Ary Borenszweig wrote:
KennyTM~ wrote:
By
far the two most important pieces of I/O functionality I need are:
1. Read a text file line-by-line.
foreach (line; new Lines!(char) (new File ("foobar.txt"))) Cout
(line).newline;
}
yuck.
Yuck?? I find that code very elegant. How would you like it to be?
Python do it like this:
for line in open("foobar.txt"):
print(line)
How many things you need to explain for that elegant code? Line? File?
Cout? .newline?
Your argumentation is getting ridiculous. Reading and printing lines of a
text file isn't by any means a good measure of standard library quality.
I could define something like
void printFileLines(string fn) { ... }
in my code and use it like this:
printFileLines("foobar.txt");
When I'm programming with a systems programming language, I really do
want to know if it reads the whole 100 GB file into memory before
iterating or if not, what kind of buffer it is using. I often also need
to work with endianess issues, codepage conversions, file system
exceptions etc. If I only need to write simple code (== programming in
the small) I might want to use some scripting language instead.
It's really hard to please both audiences without cluttering the stdlib
api.
I don't have much time to spend on std.stdio nowadays, but the clear
intent there is to provide range-based access that satisfies both
audiences by using a good abstraction instead of cluttering the API.
Andrei