Rant of the day

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Jan 25 22:00:48 UTC 2021


On Mon, Jan 25, 2021 at 09:26:28PM +0000, Tove via Digitalmars-d wrote:
> On Monday, 25 January 2021 at 20:07:04 UTC, H. S. Teoh wrote:
> > Relying on a GC-collected object to reclaim a resource (in this case
> > a mmap mapping) is an anti-pattern that should be expunged from
> > Phobos.
> > 
> > 	https://issues.dlang.org/show_bug.cgi?id=9501
[...]
> Fully agree... it was brought up ages ago, I was living in the
> delusion that someone had fixed it by now... alas.

I'd submit a PR for it, but based on the discussion in bugzilla, it
probably won't go through, because (1) changing from a class to a struct
will break pretty much *every* usage of it in existing code, and we're
oh so afraid of breaking changes these days even if it's all for the
better; (2) the anticipated back-n-forth on the ensuing PR discussion
will probably wear me out and make me walk away as quickly as I
approached.

Based on Andrei's and others' sentiment expressed within the past year
or two, probably a more viable approach is to create a new mmfile API.
Say std.mmfile2, or just have a new struct-based version of Mmfile
alongside the current class, that has better semantics and better
reflects today's language. (From the looks of it, std.mmfile was written
in an earlier era where D still had a more class-centric, Java-like
outlook, with one or two things bolted on afterwards but not really
changing the core implementation.)  I'm wary of submitting this to
Phobos, though, because the current PR process is a gigantic timesink
and time is something I do not have enough of.

At this point, a dub package or some other external module is probably a
better bet.  I'd try my hand at a standalone 1-file replacement for
std.mmfile, but I've zero Windows dev experience so it will only be
Posix-compatible.


T

-- 
Be in denial for long enough, and one day you'll deny yourself of things you wish you hadn't.


More information about the Digitalmars-d mailing list