Bug 20635 – std.file.write is not UFCS friendly

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-03-04T19:20:14Z
Last change time
2022-02-07T19:12:26Z
Assigned to
No Owner
Creator
Basile-z

Comments

Comment #0 by b2.temp — 2020-03-04T19:20:14Z
the filename is the first parameter. It would be more judicious if it was the second. e.g, you cant do that for now --- string doStuff1(string); string doStuff2(string); dirEntries(...) .map!(a => tuple(a.name, readText(a.name)) .each!(a => a[1].doStuff1() .doStuff2() .write(a[0])); // oops --- it can happen very easily, even on a simple stuff like --- buffer.write(name); --- The choice of the order is very poor. Both cases presented here happened for real. At some point if you don't take care you finish with a folder containing files with cryptic names and each of them contains a path. Hilarious. As UFCS mimics the beahior of member functions we can compare `std.file.write` to something like `MemoryStream.writeToFile()` hence the "pseudo" `this` must be for the data, not the name.