[Issue 9599] File.byLine doesn't function properly with take

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jul 22 08:32:08 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9599


Nick Treleaven <ntrel-public at yahoo.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |ntrel-public at yahoo.co.uk


--- Comment #4 from Nick Treleaven <ntrel-public at yahoo.co.uk> 2013-07-22 08:32:06 PDT ---
(In reply to comment #1)
> 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:

https://github.com/D-Programming-Language/phobos/pull/1433

>    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?

I think the above behaviour is understandable for a range like ByLine.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list