Bug 11430 – A simpler overload for std.file.slurp

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-03T07:33:34Z
Last change time
2024-12-01T16:19:03Z
Assigned to
No Owner
Creator
bearophile_hugs
Moved to GitHub: phobos#9616 →

Comments

Comment #0 by bearophile_hugs — 2013-11-03T07:33:34Z
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.)
Comment #1 by robert.schadek — 2024-12-01T16:19:03Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/9616 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB