Suggestion re the manual

Guillaume Piolat first.last at gmail.com
Thu Jun 9 14:00:49 UTC 2022


On Wednesday, 8 June 2022 at 18:34:20 UTC, Paul wrote:
> Later, a more senior developer suggested we alias these names 
> to be more readable, and easier to search for (we have a mix of 
> D code, JS, and even our own class methods with similar names).

Here is a simple Phobos trick (courtesy of Adam) that I learned 
after much time grieving about std.file short names.

**Tip:** Use `static import file = std.file;` instead of `import 
std.file`;

https://d.godbolt.org/z/cq5xejdTx

Now you have:

    - `file.read`
    - `file.write`
    - `file.exists`


It's bad that Phobos takes over the namespace with 
non-descriptive names like read/write/exists, when names like 
fileExists/fileRead/fileWrite would be better for code completion 
and discoverability. And indeed, Phobos has a lot of 
undiscoverable things because the names don't have a prefix.

But you can keep things readable anyway with `static import`.


More information about the Digitalmars-d mailing list