www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11430] New: A simpler overload for std.file.slurp

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 puremagic.com
        ReportedBy: bearophile_hugs eml.cc



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: -------
Nov 03 2013