[Issue 20635] New: std.file.write is not UFCS friendly
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Mar 4 19:20:14 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20635
Issue ID: 20635
Summary: std.file.write is not UFCS friendly
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: b2.temp at gmx.com
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.
--
More information about the Digitalmars-d-bugs
mailing list