[Issue 3868] It would be nice to have a function which read a file lazily using a range

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 19 21:08:29 PDT 2010


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


Andrei Alexandrescu <andrei at metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei at metalanguage.com


--- Comment #2 from Andrei Alexandrescu <andrei at metalanguage.com> 2010-08-19 21:08:24 PDT ---
byChunk uses opApply. We need to transform it into a range; using opApply alone
severely limits the applicability of byChunk.

Here's a nice potential application of byChunk:

import std.stdio;
void main(string[] a) {
    enforce(a.length == 3);
    auto f1 = File(a[1]), f2 = File(a[2]);
    immutable bufsize = 1024 * 1024;
    return equal(f1.byChunk(bufsize), f2.byChunk(bufsize));
}

One other idea suggested by the above is to implement the algorithm found in
diff in std.algorithm. Then we can write a diff program in a dozen line of
code, using general components.

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