Let me clarify, what I was going to create was a small utility, analogous to Perl <> operator, taking a list of file names and allowing forward iteration as it would be single stream of text lines. It would take no time to write the range from scratch, but what are all the phobos primitives for then? So it looks like this:
    auto catFiles(string[] args)
    {
        File[] files=args.map!(a => File(a)).array;
        if(files.empty)
                files~=stdin;
        return joiner(files.map!(a => a.byLine));
    }
but unfortunately it does not work.
It seems, everybody agreed the problem is likely in the line buffer reused, however, replacing .byLine() with .byLineCopy() yields same result. Also, neither .byLine() nor .byLineCopy() return ForwardRange, just InputRange, so no .save() is probably called on them. And last, the utility is supposed to be fast, so using .byLineCopy() is very undesirable. Transient ranges may be uneasy to handle, but they allow to retain status of D as "better C" suitable for system programming. Using unsolicited internal copies is more typical for high-level scripting languages, and is one of the reasons of slower execution and high memory consumption. In short, I agree with your arguments, but still believe this is a bug, probably in joiner rather than in .byLine(). I'm going to take look at the code and will tell if find anything.
Thank you for the discussion.

Reply via email to