www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9501] New: Struct std.mmfile.MmFile?

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9501

           Summary: Struct std.mmfile.MmFile?
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



Maybe it's a good idea for std.mmfile.MmFile to become a struct like
std.stdio.File, so the file is closed when this struct goes out of scope and
the reference count it keeps is zero.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 12 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9501


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



PST ---
Yes, std.mmfile.MmFile should be a struct. It doesn't use polymorphism and has
no need to be a class. But making it a struct would break all code that uses
it, so we're arguably stuck with it being the way that it is.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 12 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9501





 Yes, std.mmfile.MmFile should be a struct. It doesn't use polymorphism and has
 no need to be a class.
And maybe it doesn't have an explicit close() method, I don't know why, maybe for safety in accessing the memory mapped bytes.
 But making it a struct would break all code that uses
 it, so we're arguably stuck with it being the way that it is.
There are always acceptable deprecation paths, if we want them. Like adding the struct to std.mmfile with another name ("RcMmFile"?) and deprecating std.mmfile.MmFile for two years. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 12 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9501




Mostly unrelated, about std.mmfile: I think in the std.mmfile module this line
(line 270) should offer a string message too when the file is not found:

errnoEnforce(false);


And I think switches like this one should become "final":

            switch (mode)
            {
            case Mode.read:
...
            default:
                assert(0);
            }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 12 2013