http://d.puremagic.com/issues/show_bug.cgi?id=9599
[email protected] changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from [email protected] 2013-02-27 03:35:11 PST --- (In reply to comment #0) > Using 2.062, Regarding the following code: The bug is actually inside byLine itself, so we can remove take from the equation. The problem is that byLine is over-eager: 1) Creating a front element eagerly pops that element. 2) poping an element eagerlly parses the next, effectivelly popping it off too if it is never read: Reduced test showing this: //---- import std.stdio; void main() { auto file = File.tmpfile(); file.write("1\n2\n3\n4\n5"); file.rewind(); auto fbl1 = file.byLine(); writeln(fbl1.front); //prints 1. auto fbl2 = file.byLine(); writeln(fbl2.front); //prints 2... Wait. Who popped off 1? fbl2.popFront(); //pops off 2, and consumes 3. auto fbl3 = file.byLine(); writeln(fbl3.front); //prints 4. } //---- Ideally, byLine should be reworked to be a little more lazy, and better preserve the integrity of its underlying stream: - "front means do NOT modify the referenced container" - "pop means remove the CURRENT element, and stop there" byLine is obviously not doing that. The fact that it is *just* an input range does not mean it gets to bypass standard rules. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
