The easiest way, if you really want to suck up the entire file into memory, is
write(Array.map(Stdio.stdin->read()/"\n", process_line) * "\n");
That's nice and simple, but wastes memory. To me, the entire point of the line_iterator is to make it *equally* easy to process the file without incurring that memory waste. That means that
foreach(Stdio.stdin.line_iterator();; string x) write("%s\n", process_line(x));
must do the right thing.
The iterator you're arguing for simply doesn't do that.
To be a little constructive, I'll suggest that line_iterator behaves like gets, and handles all flavours of line termination sequences, etc, and a new one, say newline_iterator, that does exactly what / "\n" would do.
/ Niels Möller ()
Previous text:
2002-12-31 15:03: Subject: stdin->line_iterator
I would, because it looks more readable than
foreach(Stdio.stdin->read()/"\n", string line)
But that is beside the point that it is the Right Thing to do. Dropping information is not.
/ Peter Bortas