Summary: Few possible changes on std.stdio.File
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos

--- Comment #0 from 2010-08-29 16:57:23 PDT ---
This is not a bug report, it's a list of three possible small changes to the
code/API of std.stdio.File.

Here Andrei says that the method is useful for

Indeed inside File.this() there is an allocation, that open() may sometimes
save if File.Impl.refs is 1. But open() contains:

auto another = File(name, stdioOpenmode);

That calls File.this(), so at a first sight it seems that open() performs the
allocation anyway (if I am wrong then please ignore this).

Generally it's positive to minimize APIs. You may write:

auto f = File(...)
f = File(...)

Instead of:

auto f = File(...)


According to D specs on the site, inner structs contain an extra scope pointer,
so this may be better:

private static struct Impl {

See also bug 4087


Given the presence of opAssign, I presume this code, inside open():

auto another = File(name, stdioOpenmode);
swap(this, another);

May be written just as:

this = File(name, stdioOpenmode);

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to