[Issue 11430] New: A simpler overload for std.file.slurp

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 3 07:33:35 PST 2013


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

           Summary: A simpler overload for std.file.slurp
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2013-11-03 07:33:34 PST ---
I think it could be handy to add another overload of the std.file.slurp
template function. Currently (dmd 2.064) this is its usage syntax (using UFCS
for the file name), that essentially states the types two times:

const arr1 = "data.txt".slurp!(int, int)("%d, %d");


If the user wants to state them only once (more DRY) then slurp could also
accept:

const arr2 = "data.txt".slurp!"%d, %d";

This is not a replacement for the precedent syntax because the formatting
syntax is less precise ("%d %f" can only take an int and a double, so with this
syntax you can't specify a long and a real), but in many common cases I think
it's enough and it's simpler.


(In theory the API of slurp could even change, returning a lazy range, useful
for larger files.)

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